From 598a6299db2f28314928cc9ef73fc3f3748977ce Mon Sep 17 00:00:00 2001 From: Saranya Natarajan Date: Fri, 22 Aug 2025 15:20:48 +0200 Subject: [PATCH 1/2] initial fix --- src/hotspot/share/opto/idealGraphPrinter.cpp | 186 +++++++------------ src/hotspot/share/opto/idealGraphPrinter.hpp | 2 + 2 files changed, 66 insertions(+), 122 deletions(-) diff --git a/src/hotspot/share/opto/idealGraphPrinter.cpp b/src/hotspot/share/opto/idealGraphPrinter.cpp index 1ecb46eaf5ae5..dd9f6ad1c5377 100644 --- a/src/hotspot/share/opto/idealGraphPrinter.cpp +++ b/src/hotspot/share/opto/idealGraphPrinter.cpp @@ -256,6 +256,19 @@ void IdealGraphPrinter::print_prop(const char *name, const char *val) { tail(PROPERTY_ELEMENT); } +void IdealGraphPrinter::print_prop_record(const IdealGraphPrintRecord rec[], int size) { + for ( int i = 0; i < size; i++ ) { + if (rec[i].cond != 0) { + if (rec[i].string_value != nullptr) { + print_prop(rec[i].name, rec[i].string_value); + } + else { + print_prop(rec[i].name, rec[i].int_value); + } + } + } +} + void IdealGraphPrinter::print_method(ciMethod *method, int bci, InlineTree *tree) { begin_head(METHOD_ELEMENT); @@ -507,61 +520,27 @@ void IdealGraphPrinter::visit_node(Node* n, bool edges) { } const jushort flags = node->flags(); - if (flags & Node::Flag_is_Copy) { - print_prop("is_copy", "true"); - } - if (flags & Node::Flag_rematerialize) { - print_prop("rematerialize", "true"); - } - if (flags & Node::Flag_needs_anti_dependence_check) { - print_prop("needs_anti_dependence_check", "true"); - } - if (flags & Node::Flag_is_macro) { - print_prop("is_macro", "true"); - } - if (flags & Node::Flag_is_Con) { - print_prop("is_con", "true"); - } - if (flags & Node::Flag_is_cisc_alternate) { - print_prop("is_cisc_alternate", "true"); - } - if (flags & Node::Flag_is_dead_loop_safe) { - print_prop("is_dead_loop_safe", "true"); - } - if (flags & Node::Flag_may_be_short_branch) { - print_prop("may_be_short_branch", "true"); - } - if (flags & Node::Flag_has_call) { - print_prop("has_call", "true"); - } - if (flags & Node::Flag_has_swapped_edges) { - print_prop("has_swapped_edges", "true"); - } - - if (C->matcher() != nullptr) { - if (C->matcher()->is_shared(node)) { - print_prop("is_shared", "true"); - } else { - print_prop("is_shared", "false"); - } - if (C->matcher()->is_dontcare(node)) { - print_prop("is_dontcare", "true"); - } else { - print_prop("is_dontcare", "false"); - } - Node* old = C->matcher()->find_old_node(node); - if (old != nullptr) { - print_prop("old_node_idx", old->_idx); - } - } - - if (node->is_Proj()) { - print_prop("con", (int)node->as_Proj()->_con); - } - - if (node->is_Mach()) { - print_prop("idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]); - } + Node* old = C->matcher()->find_old_node(node); + const IdealGraphPrintRecord rec[] = { + {flags & Node::Flag_is_Copy, "is_copy", "true"}, + {flags & Node::Flag_rematerialize, "rematerialize", "true"}, + {flags & Node::Flag_needs_anti_dependence_check, "needs_anti_dependence_check", "true"}, + {flags & Node::Flag_is_macro, "is_macro", "true"}, + {flags & Node::Flag_is_Con, "is_con", "true"}, + {flags & Node::Flag_is_cisc_alternate, "is_cisc_alternate", "true"}, + {flags & Node::Flag_is_dead_loop_safe, "is_dead_loop_safe", "true"}, + {flags & Node::Flag_may_be_short_branch, "may_be_short_branch", "true"}, + {flags & Node::Flag_has_call, "has_call", "true"}, + {flags & Node::Flag_has_swapped_edges, "has_swapped_edges", "true"}, + {((C->matcher() != nullptr) && (C->matcher()->is_shared(node))), "is_shared", "true"}, + {((C->matcher() != nullptr) && !(C->matcher()->is_shared(node))), "is_shared", "false"}, + {((C->matcher() != nullptr) && (C->matcher()->is_dontcare(node))), "is_dontcare", "true"}, + {((C->matcher() != nullptr) && !(C->matcher()->is_dontcare(node))), "is_dontcare", "false"}, + {(old != nullptr), "old_node_idx", nullptr, (int)old->_idx}, + {(node->is_Proj()), "con", nullptr, (int)node->as_Proj()->_con}, + {node->is_Mach(), "idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]} + }; + print_prop_record(rec,(sizeof(rec)/sizeof(IdealGraphPrintRecord))); if (node->is_CountedLoop()) { print_loop_kind(node->as_CountedLoop()); @@ -1082,73 +1061,36 @@ void IdealGraphPrinter::print(const char* name, Node* node, GrowableArray { Compile *C; double _max_freq; bool _append; + struct IdealGraphPrintRecord { int cond; const char *name; const char *string_value = nullptr; int int_value = -1;}; // Walk the native stack and print relevant C2 frames as IGV properties (if // graph_name == nullptr) or the graph name based on the highest C2 frame (if @@ -138,6 +139,7 @@ class IdealGraphPrinter : public CHeapObj { void print_attr(const char *name, intptr_t val); void print_prop(const char *name, const char *val); void print_prop(const char *name, int val); + void print_prop_record(const IdealGraphPrintRecord rec[], int size); void tail(const char *name); void head(const char *name); void text(const char *s); From b9e39a5b8bbb973536ed366b23fa576636736025 Mon Sep 17 00:00:00 2001 From: Saranya Natarajan Date: Mon, 25 Aug 2025 16:28:21 +0200 Subject: [PATCH 2/2] fix to failing test --- src/hotspot/share/opto/idealGraphPrinter.cpp | 45 ++++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/hotspot/share/opto/idealGraphPrinter.cpp b/src/hotspot/share/opto/idealGraphPrinter.cpp index dd9f6ad1c5377..89c37ef314a3e 100644 --- a/src/hotspot/share/opto/idealGraphPrinter.cpp +++ b/src/hotspot/share/opto/idealGraphPrinter.cpp @@ -520,7 +520,6 @@ void IdealGraphPrinter::visit_node(Node* n, bool edges) { } const jushort flags = node->flags(); - Node* old = C->matcher()->find_old_node(node); const IdealGraphPrintRecord rec[] = { {flags & Node::Flag_is_Copy, "is_copy", "true"}, {flags & Node::Flag_rematerialize, "rematerialize", "true"}, @@ -531,17 +530,35 @@ void IdealGraphPrinter::visit_node(Node* n, bool edges) { {flags & Node::Flag_is_dead_loop_safe, "is_dead_loop_safe", "true"}, {flags & Node::Flag_may_be_short_branch, "may_be_short_branch", "true"}, {flags & Node::Flag_has_call, "has_call", "true"}, - {flags & Node::Flag_has_swapped_edges, "has_swapped_edges", "true"}, - {((C->matcher() != nullptr) && (C->matcher()->is_shared(node))), "is_shared", "true"}, - {((C->matcher() != nullptr) && !(C->matcher()->is_shared(node))), "is_shared", "false"}, - {((C->matcher() != nullptr) && (C->matcher()->is_dontcare(node))), "is_dontcare", "true"}, - {((C->matcher() != nullptr) && !(C->matcher()->is_dontcare(node))), "is_dontcare", "false"}, - {(old != nullptr), "old_node_idx", nullptr, (int)old->_idx}, - {(node->is_Proj()), "con", nullptr, (int)node->as_Proj()->_con}, - {node->is_Mach(), "idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]} + {flags & Node::Flag_has_swapped_edges, "has_swapped_edges", "true"} }; print_prop_record(rec,(sizeof(rec)/sizeof(IdealGraphPrintRecord))); + if (C->matcher() != nullptr) { + if (C->matcher()->is_shared(node)) { + print_prop("is_shared", "true"); + } else { + print_prop("is_shared", "false"); + } + if (C->matcher()->is_dontcare(node)) { + print_prop("is_dontcare", "true"); + } else { + print_prop("is_dontcare", "false"); + } + Node* old = C->matcher()->find_old_node(node); + if (old != nullptr) { + print_prop("old_node_idx", old->_idx); + } + } + + if (node->is_Proj()) { + print_prop("con", (int)node->as_Proj()->_con); + } + + if (node->is_Mach()) { + print_prop("idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]); + } + if (node->is_CountedLoop()) { print_loop_kind(node->as_CountedLoop()); } @@ -1064,7 +1081,7 @@ void IdealGraphPrinter::print(const char* name, Node* node, GrowableArray