RFR: 8355970: C2: Add command line option to print the compile phases
Roberto Castañeda Lozano
rcastanedalo at openjdk.org
Mon May 12 13:43:55 UTC 2025
On Mon, 12 May 2025 13:03:16 GMT, Manuel Hässig <mhaessig at openjdk.org> wrote:
> 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...
Thanks for working on the Manuel, looks very useful! Have you considered using the Unified Logging (UL) instead of creating a new JVM flag for this? We already have `-Xlog:jit+compilation` that seems related to this. You might print the compile phase information with e.g. `-Xlog:jit+compilation=trace`, or add a new UL tag if necessary.
We want to move towards using the UL framework in the JVM compiler components, now that the preparation work by @anton-seoane is completed.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25183#issuecomment-2872627435
More information about the hotspot-compiler-dev
mailing list