Skip to content

Commit 701bc3b

Browse files
dlunderobcasloz
authored andcommittedDec 8, 2023
8295166: IGV: dump graph at more locations
Reviewed-by: thartmann, rcastanedalo, chagedorn
1 parent 9e48b90 commit 701bc3b

File tree

15 files changed

+173
-62
lines changed

15 files changed

+173
-62
lines changed
 

‎src/hotspot/share/opto/c2_globals.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,10 @@
365365
"Level of detail of the ideal graph printout. " \
366366
"System-wide value, -1=printing is disabled, " \
367367
"0=print nothing except IGVPrintLevel directives, " \
368-
"5=all details printed. " \
368+
"6=all details printed. " \
369369
"Level of detail of printouts can be set on a per-method level " \
370370
"as well by using CompileCommand=option.") \
371-
range(-1, 5) \
371+
range(-1, 6) \
372372
\
373373
notproduct(intx, PrintIdealGraphPort, 4444, \
374374
"Ideal graph printer to network port") \

‎src/hotspot/share/opto/compile.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,10 @@ void Compile::Init(bool aliasing) {
10411041
Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
10421042
set_decompile_count(0);
10431043

1044+
#ifndef PRODUCT
1045+
Copy::zero_to_bytes(_igv_phase_iter, sizeof(_igv_phase_iter));
1046+
#endif
1047+
10441048
set_do_freq_based_layout(_directive->BlockLayoutByFrequencyOption);
10451049
_loop_opts_cnt = LoopOptsCount;
10461050
set_do_inlining(Inline);
@@ -2397,6 +2401,7 @@ void Compile::Optimize() {
23972401
if (failing()) return;
23982402

23992403
// Conditional Constant Propagation;
2404+
print_method(PHASE_BEFORE_CCP1, 2);
24002405
PhaseCCP ccp( &igvn );
24012406
assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)");
24022407
{
@@ -2972,6 +2977,8 @@ void Compile::Code_Gen() {
29722977
if (failing()) {
29732978
return;
29742979
}
2980+
2981+
print_method(PHASE_REGISTER_ALLOCATION, 2);
29752982
}
29762983

29772984
// Prior to register allocation we kept empty basic blocks in case the
@@ -2989,19 +2996,22 @@ void Compile::Code_Gen() {
29892996
cfg.fixup_flow();
29902997
cfg.remove_unreachable_blocks();
29912998
cfg.verify_dominator_tree();
2999+
print_method(PHASE_BLOCK_ORDERING, 3);
29923000
}
29933001

29943002
// Apply peephole optimizations
29953003
if( OptoPeephole ) {
29963004
TracePhase tp("peephole", &timers[_t_peephole]);
29973005
PhasePeephole peep( _regalloc, cfg);
29983006
peep.do_transform();
3007+
print_method(PHASE_PEEPHOLE, 3);
29993008
}
30003009

30013010
// Do late expand if CPU requires this.
30023011
if (Matcher::require_postalloc_expand) {
30033012
TracePhase tp("postalloc_expand", &timers[_t_postalloc_expand]);
30043013
cfg.postalloc_expand(_regalloc);
3014+
print_method(PHASE_POSTALLOC_EXPAND, 3);
30053015
}
30063016

30073017
// Convert Nodes to instruction bits in a buffer
@@ -5102,6 +5112,10 @@ void Compile::print_method(CompilerPhaseType cpt, int level, Node* n) {
51025112
ResourceMark rm;
51035113
stringStream ss;
51045114
ss.print_raw(CompilerPhaseTypeHelper::to_description(cpt));
5115+
int iter = ++_igv_phase_iter[cpt];
5116+
if (iter > 1) {
5117+
ss.print(" %d", iter);
5118+
}
51055119
if (n != nullptr) {
51065120
ss.print(": %d %s ", n->_idx, NodeClassNames[n->Opcode()]);
51075121
}

‎src/hotspot/share/opto/compile.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ class Compile : public Phase {
343343
bool _print_intrinsics; // True if we should print intrinsics for this compilation
344344
#ifndef PRODUCT
345345
uint _igv_idx; // Counter for IGV node identifiers
346+
uint _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
346347
bool _trace_opto_output;
347348
bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
348349
#endif
@@ -531,6 +532,7 @@ class Compile : public Phase {
531532

532533
#ifndef PRODUCT
533534
IdealGraphPrinter* igv_printer() { return _igv_printer; }
535+
void reset_igv_phase_iter(CompilerPhaseType cpt) { _igv_phase_iter[cpt] = 0; }
534536
#endif
535537

536538
void log_late_inline(CallGenerator* cg);

‎src/hotspot/share/opto/loopPredicate.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
11801180
}
11811181
BoolNode* bol = test->as_Bool();
11821182
if (invar.is_invariant(bol)) {
1183+
C->print_method(PHASE_BEFORE_LOOP_PREDICATION_IC, 4, iff);
11831184
// Invariant test
11841185
new_predicate_proj = create_new_if_for_predicate(parse_predicate_proj, nullptr,
11851186
reason,
@@ -1197,6 +1198,9 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
11971198
IfNode* new_predicate_iff = new_predicate_proj->in(0)->as_If();
11981199
_igvn.hash_delete(new_predicate_iff);
11991200
new_predicate_iff->set_req(1, new_predicate_bol);
1201+
1202+
C->print_method(PHASE_AFTER_LOOP_PREDICATION_IC, 4, new_predicate_proj->in(0));
1203+
12001204
#ifndef PRODUCT
12011205
if (TraceLoopPredicate) {
12021206
tty->print("Predicate invariant if%s: %d ", negated ? " negated" : "", new_predicate_iff->_idx);
@@ -1207,6 +1211,7 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
12071211
}
12081212
#endif
12091213
} else if (cl != nullptr && loop->is_range_check_if(if_success_proj, this, invar DEBUG_ONLY(COMMA parse_predicate_proj))) {
1214+
C->print_method(PHASE_BEFORE_LOOP_PREDICATION_RC, 4, iff);
12101215
// Range check for counted loops
12111216
assert(if_success_proj->is_IfTrue(), "trap must be on false projection for a range check");
12121217
const Node* cmp = bol->in(1)->as_Cmp();
@@ -1270,6 +1275,8 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
12701275
new_predicate_proj = add_template_assertion_predicate(iff, loop, if_success_proj, parse_predicate_proj, upper_bound_proj, scale,
12711276
offset, init, limit, stride, rng, overflow, reason);
12721277

1278+
C->print_method(PHASE_AFTER_LOOP_PREDICATION_RC, 4, new_predicate_proj->in(0));
1279+
12731280
#ifndef PRODUCT
12741281
if (TraceLoopOpts && !TraceLoopPredicate) {
12751282
tty->print("Predicate RC ");

‎src/hotspot/share/opto/loopTransform.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) {
703703
}
704704
#endif
705705
LoopNode* head = loop->_head->as_Loop();
706+
707+
C->print_method(PHASE_BEFORE_LOOP_PEELING, 4, head);
708+
706709
bool counted_loop = head->is_CountedLoop();
707710
if (counted_loop) {
708711
CountedLoopNode *cl = head->as_CountedLoop();
@@ -795,6 +798,8 @@ void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) {
795798
peeled_dom_test_elim(loop,old_new);
796799

797800
loop->record_for_igvn();
801+
802+
C->print_method(PHASE_AFTER_LOOP_PEELING, 4, new_head);
798803
}
799804

800805
//------------------------------policy_maximally_unroll------------------------
@@ -1629,6 +1634,8 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n
16291634
CountedLoopEndNode *main_end = main_head->loopexit();
16301635
assert(main_end->outcnt() == 2, "1 true, 1 false path only");
16311636

1637+
C->print_method(PHASE_BEFORE_PRE_MAIN_POST, 4, main_head);
1638+
16321639
Node *pre_header= main_head->in(LoopNode::EntryControl);
16331640
Node *init = main_head->init_trip();
16341641
Node *incr = main_end ->incr();
@@ -1825,6 +1832,8 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n
18251832
// finds some, but we _know_ they are all useless.
18261833
peeled_dom_test_elim(loop,old_new);
18271834
loop->record_for_igvn();
1835+
1836+
C->print_method(PHASE_AFTER_PRE_MAIN_POST, 4, main_head);
18281837
}
18291838

18301839
//------------------------------insert_vector_post_loop------------------------
@@ -2127,6 +2136,9 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
21272136
assert(LoopUnrollLimit, "");
21282137
CountedLoopNode *loop_head = loop->_head->as_CountedLoop();
21292138
CountedLoopEndNode *loop_end = loop_head->loopexit();
2139+
2140+
C->print_method(PHASE_BEFORE_LOOP_UNROLLING, 4, loop_head);
2141+
21302142
#ifndef PRODUCT
21312143
if (PrintOpto && VerifyLoopOptimizations) {
21322144
tty->print("Unrolling ");
@@ -2374,6 +2386,8 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
23742386
}
23752387
}
23762388
#endif
2389+
2390+
C->print_method(PHASE_AFTER_LOOP_UNROLLING, 4, clone_head);
23772391
}
23782392

23792393
//------------------------------do_maximally_unroll----------------------------
@@ -3003,6 +3017,8 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
30033017
// stride_con and scale_con can be negative which will flip about the
30043018
// sense of the test.
30053019

3020+
C->print_method(PHASE_BEFORE_RANGE_CHECK_ELIMINATION, 4, iff);
3021+
30063022
// Perform the limit computations in jlong to avoid overflow
30073023
jlong lscale_con = scale_con;
30083024
Node* int_offset = offset;
@@ -3103,6 +3119,9 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
31033119
--imax;
31043120
}
31053121
}
3122+
3123+
C->print_method(PHASE_AFTER_RANGE_CHECK_ELIMINATION, 4, cl);
3124+
31063125
} // End of is IF
31073126
}
31083127
if (loop_entry != cl->skip_strip_mined()->in(LoopNode::EntryControl)) {

‎src/hotspot/share/opto/loopUnswitch.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ void PhaseIdealLoop::do_unswitching(IdealLoopTree *loop, Node_List &old_new) {
134134
}
135135
#endif
136136

137+
C->print_method(PHASE_BEFORE_LOOP_UNSWITCHING, 4, head);
138+
137139
// Need to revert back to normal loop
138140
if (head->is_CountedLoop() && !head->as_CountedLoop()->is_normal_loop()) {
139141
head->as_CountedLoop()->set_normal_loop();
@@ -200,6 +202,8 @@ void PhaseIdealLoop::do_unswitching(IdealLoopTree *loop, Node_List &old_new) {
200202
}
201203
#endif
202204

205+
C->print_method(PHASE_AFTER_LOOP_UNSWITCHING, 4, head_clone);
206+
203207
C->set_major_progress();
204208
}
205209

‎src/hotspot/share/opto/loopopts.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,12 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) {
14461446
}
14471447

14481448
// Now split the IF
1449+
C->print_method(PHASE_BEFORE_SPLIT_IF, 4, iff);
1450+
if ((PrintOpto && VerifyLoopOptimizations) || TraceLoopOpts) {
1451+
tty->print_cr("Split-If");
1452+
}
14491453
do_split_if(iff);
1454+
C->print_method(PHASE_AFTER_SPLIT_IF, 4, iff);
14501455
return;
14511456
}
14521457

@@ -3625,6 +3630,9 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) {
36253630
}
36263631
}
36273632
#endif
3633+
3634+
C->print_method(PHASE_BEFORE_PARTIAL_PEELING, 4, head);
3635+
36283636
VectorSet peel;
36293637
VectorSet not_peel;
36303638
Node_List peel_list;
@@ -3919,6 +3927,9 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) {
39193927
}
39203928
}
39213929
#endif
3930+
3931+
C->print_method(PHASE_AFTER_PARTIAL_PEELING, 4, new_head_clone);
3932+
39223933
return true;
39233934
}
39243935

‎src/hotspot/share/opto/parse2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2779,7 +2779,7 @@ void Parse::do_one_bytecode() {
27792779
}
27802780

27812781
#ifndef PRODUCT
2782-
constexpr int perBytecode = 5;
2782+
constexpr int perBytecode = 6;
27832783
if (C->should_print_igv(perBytecode)) {
27842784
IdealGraphPrinter* printer = C->igv_printer();
27852785
char buffer[256];

‎src/hotspot/share/opto/phaseX.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ void PhaseIterGVN::verify_step(Node* n) {
894894
void PhaseIterGVN::trace_PhaseIterGVN(Node* n, Node* nn, const Type* oldtype) {
895895
const Type* newtype = type_or_null(n);
896896
if (nn != n || oldtype != newtype) {
897-
C->print_method(PHASE_AFTER_ITER_GVN_STEP, 4, n);
897+
C->print_method(PHASE_AFTER_ITER_GVN_STEP, 5, n);
898898
}
899899
if (TraceIterativeGVN) {
900900
uint wlsize = _worklist.size();
@@ -1025,6 +1025,7 @@ void PhaseIterGVN::trace_PhaseIterGVN_verbose(Node* n, int num_processed) {
10251025
void PhaseIterGVN::optimize() {
10261026
DEBUG_ONLY(uint num_processed = 0;)
10271027
NOT_PRODUCT(init_verifyPhaseIterGVN();)
1028+
NOT_PRODUCT(C->reset_igv_phase_iter(PHASE_AFTER_ITER_GVN_STEP);)
10281029
C->print_method(PHASE_BEFORE_ITER_GVN, 3);
10291030
if (StressIGVN) {
10301031
shuffle_worklist();

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Dec 8, 2023

@openjdk-notifier[bot]
Please sign in to comment.