Commit e5339351 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[maglev] Print control nodes while tracing the graph builder

Since targets might not yet exist, we skip them.

Bug: v8:7700
Change-Id: I6ae8a4fd7cbba3ead1f1a13865841d631796090d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3823121
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82332}
parent f97f7d79
......@@ -722,8 +722,9 @@ class MaglevGraphBuilder {
template <typename ControlNodeT, typename... Args>
BasicBlock* CreateBlock(std::initializer_list<ValueNode*> control_inputs,
Args&&... args) {
current_block_->set_control_node(CreateNewNode<ControlNodeT>(
control_inputs, std::forward<Args>(args)...));
ControlNode* control_node = CreateNewNode<ControlNodeT>(
control_inputs, std::forward<Args>(args)...);
current_block_->set_control_node(control_node);
BasicBlock* block = current_block_;
current_block_ = nullptr;
......@@ -731,6 +732,13 @@ class MaglevGraphBuilder {
graph()->Add(block);
if (has_graph_labeller()) {
graph_labeller()->RegisterBasicBlock(block);
if (FLAG_trace_maglev_graph_building) {
bool kSkipTargets = true;
std::cout << " " << control_node << " "
<< PrintNodeLabel(graph_labeller(), control_node) << ": "
<< PrintNode(graph_labeller(), control_node, kSkipTargets)
<< std::endl;
}
}
return block;
}
......
......@@ -33,7 +33,7 @@ class MaglevGraphLabeller {
int max_node_id() const { return next_node_id_ - 1; }
void PrintNodeLabel(std::ostream& os, const Node* node) {
void PrintNodeLabel(std::ostream& os, const NodeBase* node) {
auto node_id_it = node_ids_.find(node);
if (node_id_it == node_ids_.end()) {
......
......@@ -618,7 +618,7 @@ void PrintGraph(std::ostream& os, MaglevCompilationInfo* compilation_info,
}
void PrintNode::Print(std::ostream& os) const {
node_->Print(os, graph_labeller_);
node_->Print(os, graph_labeller_, skip_targets_);
}
std::ostream& operator<<(std::ostream& os, const PrintNode& printer) {
......
......@@ -52,28 +52,34 @@ void PrintGraph(std::ostream& os, MaglevCompilationInfo* compilation_info,
class PrintNode {
public:
PrintNode(MaglevGraphLabeller* graph_labeller, const NodeBase* node)
: graph_labeller_(graph_labeller), node_(node) {}
PrintNode(MaglevGraphLabeller* graph_labeller, const NodeBase* node,
bool skip_targets = false)
: graph_labeller_(graph_labeller),
node_(node),
skip_targets_(skip_targets) {}
void Print(std::ostream& os) const;
private:
MaglevGraphLabeller* graph_labeller_;
const NodeBase* node_;
// This is used when tracing graph building, since targets might not exist
// yet.
const bool skip_targets_;
};
std::ostream& operator<<(std::ostream& os, const PrintNode& printer);
class PrintNodeLabel {
public:
PrintNodeLabel(MaglevGraphLabeller* graph_labeller, const Node* node)
PrintNodeLabel(MaglevGraphLabeller* graph_labeller, const NodeBase* node)
: graph_labeller_(graph_labeller), node_(node) {}
void Print(std::ostream& os) const;
private:
MaglevGraphLabeller* graph_labeller_;
const Node* node_;
const NodeBase* node_;
};
std::ostream& operator<<(std::ostream& os, const PrintNodeLabel& printer);
......
......@@ -572,22 +572,24 @@ void PrintTargets(std::ostream& os, MaglevGraphLabeller* graph_labeller,
template <typename NodeT>
void PrintImpl(std::ostream& os, MaglevGraphLabeller* graph_labeller,
const NodeT* node) {
const NodeT* node, bool skip_targets) {
os << node->opcode();
node->PrintParams(os, graph_labeller);
PrintInputs(os, graph_labeller, node);
PrintResult(os, graph_labeller, node);
PrintTargets(os, graph_labeller, node);
if (!skip_targets) {
PrintTargets(os, graph_labeller, node);
}
}
} // namespace
void NodeBase::Print(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
void NodeBase::Print(std::ostream& os, MaglevGraphLabeller* graph_labeller,
bool skip_targets) const {
switch (opcode()) {
#define V(Name) \
case Opcode::k##Name: \
return PrintImpl(os, graph_labeller, this->Cast<Name>());
return PrintImpl(os, graph_labeller, this->Cast<Name>(), skip_targets);
NODE_BASE_LIST(V)
#undef V
}
......
......@@ -716,7 +716,8 @@ class NodeBase : public ZoneObject {
void assign_temporaries(RegList list) { temporaries_ = list; }
void Print(std::ostream& os, MaglevGraphLabeller*) const;
void Print(std::ostream& os, MaglevGraphLabeller*,
bool skip_targets = false) const;
EagerDeoptInfo* eager_deopt_info() {
DCHECK(properties().can_eager_deopt());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment