From 8a95e29b87bf9f1c1719aced734b763a3572d72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Casta=C3=B1eda=20Lozano?= Date: Mon, 11 Nov 2024 15:14:47 +0100 Subject: [PATCH 1/4] Dump graph at intermediate register allocation points --- src/hotspot/share/opto/chaitin.cpp | 28 +++++++++++++++++++ src/hotspot/share/opto/phasetype.hpp | 9 ++++++ .../lib/ir_framework/CompilePhase.java | 9 ++++++ 3 files changed, 46 insertions(+) diff --git a/src/hotspot/share/opto/chaitin.cpp b/src/hotspot/share/opto/chaitin.cpp index be0aadacbc2b9..21854dd027167 100644 --- a/src/hotspot/share/opto/chaitin.cpp +++ b/src/hotspot/share/opto/chaitin.cpp @@ -424,6 +424,9 @@ void PhaseChaitin::Register_Allocate() { live.compute(_lrg_map.max_lrg_id()); _live = &live; } + + C->print_method(PHASE_INITIAL_LIVENESS, 4); + // Create the interference graph using virtual copies build_ifg_virtual(); // Include stack slots this time @@ -464,6 +467,8 @@ void PhaseChaitin::Register_Allocate() { _live = &live; } + C->print_method(PHASE_AGGRESSIVE_COALESCING, 4); + // Build physical interference graph uint must_spill = 0; must_spill = build_ifg_physical(&live_arena); @@ -504,6 +509,9 @@ void PhaseChaitin::Register_Allocate() { live.compute(_lrg_map.max_lrg_id()); // Compute LIVE _live = &live; } + + C->print_method(PHASE_INITIAL_SPILLING, 4); + build_ifg_physical(&live_arena); _ifg->SquareUp(); _ifg->Compute_Effective_Degree(); @@ -518,6 +526,10 @@ void PhaseChaitin::Register_Allocate() { } _lrg_map.compress_uf_map_for_nodes(); + if (OptoCoalesce) { + C->print_method(PHASE_CONSERVATIVE_COALESCING, 4); + } + #ifdef ASSERT verify(&live_arena, true); #endif @@ -580,6 +592,9 @@ void PhaseChaitin::Register_Allocate() { live.compute(_lrg_map.max_lrg_id()); _live = &live; } + + C->print_method(PHASE_ITERATIVE_SPILLING, 4); + must_spill = build_ifg_physical(&live_arena); _ifg->SquareUp(); _ifg->Compute_Effective_Degree(); @@ -593,6 +608,11 @@ void PhaseChaitin::Register_Allocate() { coalesce.coalesce_driver(); } _lrg_map.compress_uf_map_for_nodes(); + + if (OptoCoalesce) { + C->print_method(PHASE_CONSERVATIVE_COALESCING, 4); + } + #ifdef ASSERT verify(&live_arena, true); #endif @@ -607,6 +627,8 @@ void PhaseChaitin::Register_Allocate() { spills = Select(); } + C->print_method(PHASE_AFTER_ITERATIVE_SPILLING, 4); + // Count number of Simplify-Select trips per coloring success. _allocator_attempts += _trip_cnt + 1; _allocator_successes += 1; @@ -614,9 +636,13 @@ void PhaseChaitin::Register_Allocate() { // Peephole remove copies post_allocate_copy_removal(); + C->print_method(PHASE_POST_ALLOCATION_COPY_REMOVAL, 4); + // Merge multidefs if multiple defs representing the same value are used in a single block. merge_multidefs(); + C->print_method(PHASE_MERGE_MULTIDEFS, 4); + #ifdef ASSERT // Verify the graph after RA. verify(&live_arena); @@ -645,6 +671,8 @@ void PhaseChaitin::Register_Allocate() { // Convert CISC spills fixup_spills(); + C->print_method(PHASE_FIXUP_SPILLS, 4); + // Log regalloc results CompileLog* log = Compile::current()->log(); if (log != nullptr) { diff --git a/src/hotspot/share/opto/phasetype.hpp b/src/hotspot/share/opto/phasetype.hpp index 7a83f8c7f27d9..ac1af2564e1b0 100644 --- a/src/hotspot/share/opto/phasetype.hpp +++ b/src/hotspot/share/opto/phasetype.hpp @@ -93,6 +93,15 @@ flags(BEFORE_MATCHING, "Before matching") \ flags(MATCHING, "After matching") \ flags(GLOBAL_CODE_MOTION, "Global code motion") \ + flags(INITIAL_LIVENESS, "Initial liveness") \ + flags(AGGRESSIVE_COALESCING, "Aggressive coalescing") \ + flags(INITIAL_SPILLING, "Initial spilling") \ + flags(CONSERVATIVE_COALESCING, "Conservative coalescing") \ + flags(ITERATIVE_SPILLING, "Iterative spilling") \ + flags(AFTER_ITERATIVE_SPILLING, "After iterative spilling") \ + flags(POST_ALLOCATION_COPY_REMOVAL, "Post-allocation copy removal") \ + flags(MERGE_MULTIDEFS, "Merge multiple definitions") \ + flags(FIXUP_SPILLS, "Fix up spills") \ flags(REGISTER_ALLOCATION, "Register Allocation") \ flags(BLOCK_ORDERING, "Block Ordering") \ flags(PEEPHOLE, "Peephole") \ diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java index 3ee8fc8f45bcd..ff89ab2676bf6 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java @@ -104,6 +104,15 @@ public enum CompilePhase { BEFORE_MATCHING("Before matching"), MATCHING("After matching", RegexType.MACH), GLOBAL_CODE_MOTION("Global code motion", RegexType.MACH), + INITIAL_LIVENESS("Initial liveness"), RegexType.MACH), + AGGRESSIVE_COALESCING("Aggressive coalescing"), RegexType.MACH), + INITIAL_SPILLING("Initial spilling"), RegexType.MACH), + CONSERVATIVE_COALESCING("Conservative coalescing"), RegexType.MACH, ActionOnRepeat.KEEP_FIRST), + ITERATIVE_SPILLING("Iterative spilling"), RegexType.MACH, ActionOnRepeat.KEEP_FIRST), + AFTER_ITERATIVE_SPILLING("After iterative spilling"), RegexType.MACH), + POST_ALLOCATION_COPY_REMOVAL("Post-allocation copy removal"), RegexType.MACH), + MERGE_MULTIDEFS("Merge multiple definitions"), RegexType.MACH), + FIXUP_SPILLS("Fix up spills"), RegexType.MACH), REGISTER_ALLOCATION("Register Allocation", RegexType.MACH), BLOCK_ORDERING("Block Ordering", RegexType.MACH), PEEPHOLE("Peephole", RegexType.MACH), From 90f9a24ecdb663166a33f986629fad8b32147aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Casta=C3=B1eda=20Lozano?= Date: Mon, 11 Nov 2024 15:49:00 +0100 Subject: [PATCH 2/4] Fix IR framework definitions --- .../lib/ir_framework/CompilePhase.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java index ff89ab2676bf6..4ad564801c258 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java @@ -104,15 +104,15 @@ public enum CompilePhase { BEFORE_MATCHING("Before matching"), MATCHING("After matching", RegexType.MACH), GLOBAL_CODE_MOTION("Global code motion", RegexType.MACH), - INITIAL_LIVENESS("Initial liveness"), RegexType.MACH), - AGGRESSIVE_COALESCING("Aggressive coalescing"), RegexType.MACH), - INITIAL_SPILLING("Initial spilling"), RegexType.MACH), - CONSERVATIVE_COALESCING("Conservative coalescing"), RegexType.MACH, ActionOnRepeat.KEEP_FIRST), - ITERATIVE_SPILLING("Iterative spilling"), RegexType.MACH, ActionOnRepeat.KEEP_FIRST), - AFTER_ITERATIVE_SPILLING("After iterative spilling"), RegexType.MACH), - POST_ALLOCATION_COPY_REMOVAL("Post-allocation copy removal"), RegexType.MACH), - MERGE_MULTIDEFS("Merge multiple definitions"), RegexType.MACH), - FIXUP_SPILLS("Fix up spills"), RegexType.MACH), + INITIAL_LIVENESS("Initial liveness", RegexType.MACH), + AGGRESSIVE_COALESCING("Aggressive coalescing", RegexType.MACH), + INITIAL_SPILLING("Initial spilling", RegexType.MACH), + CONSERVATIVE_COALESCING("Conservative coalescing", RegexType.MACH, ActionOnRepeat.KEEP_FIRST), + ITERATIVE_SPILLING("Iterative spilling", RegexType.MACH, ActionOnRepeat.KEEP_FIRST), + AFTER_ITERATIVE_SPILLING("After iterative spilling", RegexType.MACH), + POST_ALLOCATION_COPY_REMOVAL("Post-allocation copy removal", RegexType.MACH), + MERGE_MULTIDEFS("Merge multiple definitions", RegexType.MACH), + FIXUP_SPILLS("Fix up spills", RegexType.MACH), REGISTER_ALLOCATION("Register Allocation", RegexType.MACH), BLOCK_ORDERING("Block Ordering", RegexType.MACH), PEEPHOLE("Peephole", RegexType.MACH), From e44fa796ddd385f853e0ab674c558ab6c4ac3feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Casta=C3=B1eda=20Lozano?= Date: Tue, 12 Nov 2024 11:44:36 +0100 Subject: [PATCH 3/4] Split FIXUP_SPILLS --- src/hotspot/share/opto/chaitin.cpp | 2 +- src/hotspot/share/opto/phasetype.hpp | 2 +- test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/opto/chaitin.cpp b/src/hotspot/share/opto/chaitin.cpp index 21854dd027167..55bf859cc6c14 100644 --- a/src/hotspot/share/opto/chaitin.cpp +++ b/src/hotspot/share/opto/chaitin.cpp @@ -671,7 +671,7 @@ void PhaseChaitin::Register_Allocate() { // Convert CISC spills fixup_spills(); - C->print_method(PHASE_FIXUP_SPILLS, 4); + C->print_method(PHASE_FIX_UP_SPILLS, 4); // Log regalloc results CompileLog* log = Compile::current()->log(); diff --git a/src/hotspot/share/opto/phasetype.hpp b/src/hotspot/share/opto/phasetype.hpp index ac1af2564e1b0..c86b0ad5ae184 100644 --- a/src/hotspot/share/opto/phasetype.hpp +++ b/src/hotspot/share/opto/phasetype.hpp @@ -101,7 +101,7 @@ flags(AFTER_ITERATIVE_SPILLING, "After iterative spilling") \ flags(POST_ALLOCATION_COPY_REMOVAL, "Post-allocation copy removal") \ flags(MERGE_MULTIDEFS, "Merge multiple definitions") \ - flags(FIXUP_SPILLS, "Fix up spills") \ + flags(FIX_UP_SPILLS, "Fix up spills") \ flags(REGISTER_ALLOCATION, "Register Allocation") \ flags(BLOCK_ORDERING, "Block Ordering") \ flags(PEEPHOLE, "Peephole") \ diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java index 4ad564801c258..9615a04143550 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java @@ -112,7 +112,7 @@ public enum CompilePhase { AFTER_ITERATIVE_SPILLING("After iterative spilling", RegexType.MACH), POST_ALLOCATION_COPY_REMOVAL("Post-allocation copy removal", RegexType.MACH), MERGE_MULTIDEFS("Merge multiple definitions", RegexType.MACH), - FIXUP_SPILLS("Fix up spills", RegexType.MACH), + FIX_UP_SPILLS("Fix up spills", RegexType.MACH), REGISTER_ALLOCATION("Register Allocation", RegexType.MACH), BLOCK_ORDERING("Block Ordering", RegexType.MACH), PEEPHOLE("Peephole", RegexType.MACH), From fb35674f864d9794c0c92bdf36617367dcc09fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Casta=C3=B1eda=20Lozano?= Date: Tue, 12 Nov 2024 17:45:07 +0100 Subject: [PATCH 4/4] Split MERGE_MULTIDEFS --- src/hotspot/share/opto/chaitin.cpp | 2 +- src/hotspot/share/opto/phasetype.hpp | 2 +- test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/opto/chaitin.cpp b/src/hotspot/share/opto/chaitin.cpp index 55bf859cc6c14..c7c8572df8005 100644 --- a/src/hotspot/share/opto/chaitin.cpp +++ b/src/hotspot/share/opto/chaitin.cpp @@ -641,7 +641,7 @@ void PhaseChaitin::Register_Allocate() { // Merge multidefs if multiple defs representing the same value are used in a single block. merge_multidefs(); - C->print_method(PHASE_MERGE_MULTIDEFS, 4); + C->print_method(PHASE_MERGE_MULTI_DEFS, 4); #ifdef ASSERT // Verify the graph after RA. diff --git a/src/hotspot/share/opto/phasetype.hpp b/src/hotspot/share/opto/phasetype.hpp index c86b0ad5ae184..dcdf3aa3f8612 100644 --- a/src/hotspot/share/opto/phasetype.hpp +++ b/src/hotspot/share/opto/phasetype.hpp @@ -100,7 +100,7 @@ flags(ITERATIVE_SPILLING, "Iterative spilling") \ flags(AFTER_ITERATIVE_SPILLING, "After iterative spilling") \ flags(POST_ALLOCATION_COPY_REMOVAL, "Post-allocation copy removal") \ - flags(MERGE_MULTIDEFS, "Merge multiple definitions") \ + flags(MERGE_MULTI_DEFS, "Merge multiple definitions") \ flags(FIX_UP_SPILLS, "Fix up spills") \ flags(REGISTER_ALLOCATION, "Register Allocation") \ flags(BLOCK_ORDERING, "Block Ordering") \ diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java index 9615a04143550..316eb5f3ce6e0 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java @@ -111,7 +111,7 @@ public enum CompilePhase { ITERATIVE_SPILLING("Iterative spilling", RegexType.MACH, ActionOnRepeat.KEEP_FIRST), AFTER_ITERATIVE_SPILLING("After iterative spilling", RegexType.MACH), POST_ALLOCATION_COPY_REMOVAL("Post-allocation copy removal", RegexType.MACH), - MERGE_MULTIDEFS("Merge multiple definitions", RegexType.MACH), + MERGE_MULTI_DEFS("Merge multiple definitions", RegexType.MACH), FIX_UP_SPILLS("Fix up spills", RegexType.MACH), REGISTER_ALLOCATION("Register Allocation", RegexType.MACH), BLOCK_ORDERING("Block Ordering", RegexType.MACH),