RFR: 8355970: C2: Add command line option to print the compile phases [v6]

Manuel Hässig mhaessig at openjdk.org
Wed May 14 15:00:30 UTC 2025


> This PR introduces the flag `-XX:PrintPhaseLevel` that works like the flag `-XX:PrintIdealGraphLevel` and prints the name phases of a C2 compilation (essentially what we have in the left side bar in IGV) to the terminal. This allows redirecting the output to a file and comparing phase decisions between two compilations. Further, it is useful in conjunction with loop opts tracing to immediately see in which phase a certain optimization happened.
> 
> <details>
> <summary>Output with `-XX:PrintPhaseLevel=2`</summary>
> 
> 
>> java-fastdebug -Xbatch -XX:CompileCommand=compileonly,TestLoop.test10 -XX:CompileCommand=printcompilation,TestLoop.test* -XX:PrintPhaseLevel=2 TestLoop.java
> CompileCommand: compileonly TestLoop.test10 bool compileonly = true
> CompileCommand: PrintCompilation TestLoop.test* bool PrintCompilation = true
> 3577   98 %  b  3       TestLoop::test10 @ 2 (64 bytes)
> 3584   99    b  3       TestLoop::test10 (64 bytes)
> 3648  100 %  b  4       TestLoop::test10 @ 2 (64 bytes)
> 1.      After Parsing
> 2.      Iter GVN 1
> 3.      Incremental Inline
> 4.      Incremental Boxing Inline
> 5.      Before Loop Optimizations
> 6.      PhaseIdealLoop 1
> 7.      PhaseIdealLoop 2
> 8.      PhaseIdealLoop 3
> 9.      Before PhaseCCP 1
> 10.     PhaseCCP 1
> 11.     Iter GVN 2
> 12.     PhaseIdealLoop iterations
> 13.     After Loop Optimizations
> 14.     After Macro Expansion
> 15.     Barrier expand
> 16.     Optimize finished
> 17.     Before matching
> 18.     After matching
> 19.     Global code motion
> 20.     Register Allocation
> 21.     Final Code
> 3668  103    b  4       TestLoop::test10 (64 bytes)
> 1.      After Parsing
> 2.      Iter GVN 1
> 3.      Incremental Inline
> 4.      Incremental Boxing Inline
> 5.      Before Loop Optimizations
> 6.      PhaseIdealLoop 1
> 7.      PhaseIdealLoop 2
> 8.      PhaseIdealLoop 3
> 9.      Before PhaseCCP 1
> 10.     PhaseCCP 1
> 11.     Iter GVN 2
> 12.     PhaseIdealLoop iterations
> 13.     PhaseIdealLoop iterations 2
> 14.     PhaseIdealLoop iterations 3
> 15.     PhaseIdealLoop iterations 4
> 16.     PhaseIdealLoop iterations 5
> 17.     PhaseIdealLoop iterations 6
> 18.     PhaseIdealLoop iterations 7
> 19.     PhaseIdealLoop iterations 8
> 20.     PhaseIdealLoop iterations 9
> 21.     After Loop Optimizations
> 22.     After Macro Expansion
> 23.     Barrier expand
> 24.     Optimize finished
> 25.     Before matching
> 26.     After matching
> 27.     Global code motion
> 28.     Register Allocation
> 29.     Final Code
> 
> </details>
> 
> <details>
> <summary>Output with `-XX:PrintPhaseLevel=2` in conjunction with loo...

Manuel Hässig has updated the pull request incrementally with one additional commit since the last revision:

  Apply suggestions from @chhagedorn
  
  Co-authored-by: Christian Hagedorn <christian.hagedorn at oracle.com>

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/25183/files
  - new: https://git.openjdk.org/jdk/pull/25183/files/06b9d49a..69873d35

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=25183&range=05
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25183&range=04-05

  Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/25183.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25183/head:pull/25183

PR: https://git.openjdk.org/jdk/pull/25183


More information about the hotspot-compiler-dev mailing list