Instead of bailing out of IR matching when encountering the "<!-- safepoint while printing -->" message, we should extend the HotSpotPidFileParser to handle this case. This would allow us to get rid of this special case handling in IR matching.
Original report:
With the following VM change, that should be harmless, TestCompareUnsigned.java fails intermittently (1/10):
diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp
index 1ecefbe26c2..b463268dd68 100644
--- a/src/hotspot/share/code/codeCache.cpp
+++ b/src/hotspot/share/code/codeCache.cpp
@@ -1435,7 +1435,7 @@ void CodeCache::flush_dependents_on(InstanceKlass* dependee) {
marked = mark_for_deoptimization(changes);
}
- if (marked > 0) {
+ if (true) {
// At least one nmethod has been marked for deoptimization
Deoptimization::deoptimize_all_marked();
}
Run Test VM:
Command line: [/oracle/jdk/build/fastdebug/jdk/bin/java -cp /oracle/jdk/open/JTwork/classes/compiler/intrinsics/TestCompareUnsigned.d:/oracle/jdk/open/test/hotspot/jtreg/compiler/intrinsics:/oracle/jdk/open/JTwork/classes/test/lib:/oracle/jdk/open/test/lib:/oracle/jdk/open/JTwork/classes:/oracle/jdk/open/test/hotspot/jtreg:/home/tobias/programs/jtreg/lib/javatest.jar:/home/tobias/programs/jtreg/lib/jtreg.jar -Djava.library.path=. -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Dir.framework.server.port=40681 -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:CompilerDirectivesFile=test-vm-compile-commands-pid-560669.log -XX:CompilerDirectivesLimit=131 -XX:-OmitStackTraceInFastThrow -DShouldDoIRVerification=true -XX:-BackgroundCompilation -XX:CompileCommand=quiet -DWarmup=1 compiler.lib.ir_framework.test.TestVM compiler.intrinsics.TestCompareUnsigned ]
[2023-01-17T15:06:39.310899397Z] Gathering output for process 560694
[2023-01-17T15:06:41.293900861Z] Waiting for completion for process 560694
[2023-01-17T15:06:41.294021205Z] Waiting for completion finished for process 560694
Output and diagnostic info for process 560694 was saved into 'pid-560694-output.log'
[2023-01-17T15:06:41.309555163Z] Waiting for completion for process 560694
[2023-01-17T15:06:41.309656107Z] Waiting for completion finished for process 560694
Compilation of Failed Method
----------------------------
1) Compilation of "public int compiler.intrinsics.TestCompareUnsigned.lessThanInt(int,int)":
> Phase "PrintIdeal":
<empty>
STDERR:
Command Line:
/oracle/jdk/build/fastdebug/jdk/bin/java -DReproduce=true -cp /oracle/jdk/open/JTwork/classes/compiler/intrinsics/TestCompareUnsigned.d:/oracle/jdk/open/test/hotspot/jtreg/compiler/intrinsics:/oracle/jdk/open/JTwork/classes/test/lib:/oracle/jdk/open/test/lib:/oracle/jdk/open/JTwork/classes:/oracle/jdk/open/test/hotspot/jtreg:/home/tobias/programs/jtreg/lib/javatest.jar:/home/tobias/programs/jtreg/lib/jtreg.jar -Djava.library.path=. -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Dir.framework.server.port=40681 -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:CompilerDirectivesFile=test-vm-compile-commands-pid-560669.log -XX:CompilerDirectivesLimit=131 -XX:-OmitStackTraceInFastThrow -DShouldDoIRVerification=true -XX:-BackgroundCompilation -XX:CompileCommand=quiet -DWarmup=1 compiler.lib.ir_framework.test.TestVM compiler.intrinsics.TestCompareUnsigned
One or more @IR rules failed:
Failed IR Rules (2) of Methods (1)
----------------------------------
1) Method "public int compiler.intrinsics.TestCompareUnsigned.lessThanInt(int,int)" - [Failed IR rules: 2]:
* @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeatureOr={}, applyIfCPUFeature={}, counts={}, failOn={"_#CMP_U3#_"}, applyIfAnd={}, applyIfOr={}, applyIfNot={})"
> Phase "PrintIdeal":
- NO compilation output found for this phase! Make sure this phase is emitted or remove it from the list of compile phases in the @IR rule to match on.
* @IR rule 2: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeatureOr={}, applyIfCPUFeature={}, counts={"_#CMP_U#_", "1"}, failOn={}, applyIfAnd={}, applyIfOr={}, applyIfNot={})"
> Phase "PrintIdeal":
- NO compilation output found for this phase! Make sure this phase is emitted or remove it from the list of compile phases in the @IR rule to match on.
>>> Check stdout for compilation output of the failed methods
#############################################################
- To only run the failed tests use -DTest, -DExclude,
and/or -DScenarios.
- To also get the standard output of the test VM run with
-DReportStdout=true or for even more fine-grained logging
use -DVerbose=true.
#############################################################
compiler.lib.ir_framework.driver.irmatching.IRViolationException: There were one or multiple IR rule failures. Please check stderr for more information.
at compiler.lib.ir_framework.driver.irmatching.IRMatcher.throwIfNoSafepointWhilePrinting(IRMatcher.java:72)
at compiler.lib.ir_framework.driver.irmatching.IRMatcher.reportFailures(IRMatcher.java:62)
at compiler.lib.ir_framework.driver.irmatching.IRMatcher.match(IRMatcher.java:50)
at compiler.lib.ir_framework.TestFramework.runTestVM(TestFramework.java:754)
at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:719)
at compiler.lib.ir_framework.TestFramework.start(TestFramework.java:339)
at compiler.intrinsics.TestCompareUnsigned.main(TestCompareUnsigned.java:45)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125)
at java.base/java.lang.Thread.run(Thread.java:1623)