RFR(S): 8231988: Unexpected test result caused by C2 IdealLoopTree::do_remove_empty_loop
Yangfei (Felix)
felix.yang at huawei.com
Wed Oct 9 08:35:02 UTC 2019
Hi,
Webrev: http://cr.openjdk.java.net/~fyang/8231988/webrev.00/
Note that the Test::mainTest method was compiled by C2 for two times. The bug triggers for the second C2 compile.
JTreg tested on aarch64 linux platform. Is it OK?
Thanks for your help,
Felix
From: Yangfei (Felix)
Sent: Tuesday, October 8, 2019 4:14 PM
To: 'hotspot-compiler-dev at openjdk.java.net' <hotspot-compiler-dev at openjdk.java.net>
Subject: RFR(S): 8231988: Unexpected test result caused by C2 IdealLoopTree::do_remove_empty_loop
Hi,
Could I have a review for this trivial C2 bugfix please?
Bug: https://bugs.openjdk.java.net/browse/JDK-8231988
This bug is always reproducible with 8u, 11u, 13 and latest 14.
After some investigation, we found that the cmp node in one empty loop was deleted by IdealLoopTree::do_remove_empty_loop, but it still has another user outside the empty loop.
C2 call stack:
#0 IdealLoopTree::do_remove_empty_loop (this=0x96b060, phase=0xffff5c3815c0) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopTransform.cpp:3131
#1 0x0000ffffb7077f70 in IdealLoopTree::iteration_split_impl (this=0x96b060, phase=0xffff5c3815c0, old_new=...)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopTransform.cpp:3186
#2 0x0000ffffb7078590 in IdealLoopTree::iteration_split (this=0x96b060, phase=0xffff5c3815c0, old_new=...)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopTransform.cpp:3336
#3 0x0000ffffb70784a8 in IdealLoopTree::iteration_split (this=0x96b130, phase=0xffff5c3815c0, old_new=...)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopTransform.cpp:3320
#4 0x0000ffffb708a2c8 in PhaseIdealLoop::build_and_optimize (this=0xffff5c3815c0, mode=LoopOptsDefault)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopnode.cpp:3088
#5 0x0000ffffb6a46e58 in PhaseIdealLoop::PhaseIdealLoop (this=0xffff5c3815c0, igvn=..., mode=LoopOptsDefault)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopnode.hpp:945
#6 0x0000ffffb6a46f18 in PhaseIdealLoop::optimize (igvn=..., mode=LoopOptsDefault) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopnode.hpp:1020
#7 0x0000ffffb6a3abc8 in Compile::Optimize (this=0xffff5c3847a8) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/compile.cpp:2328
#8 0x0000ffffb6a3458c in Compile::Compile (this=0xffff5c3847a8, ci_env=0xffff5c385558, compiler=0xffff581e2110, target=0x928e20, osr_bci=-1,
subsume_loads=true, do_escape_analysis=true, eliminate_boxing=true, directive=0xffff581b1e70)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/compile.cpp:874
#9 0x0000ffffb690a508 in C2Compiler::compile_method (this=0xffff581e2110, env=0xffff5c385558, target=0x928e20, entry_bci=-1, directive=0xffff581b1e70)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/c2compiler.cpp:110
#10 0x0000ffffb6a506c8 in CompileBroker::invoke_compiler_on_method (task=0xffff5824df80)
at /home/yangfei/openjdk-jdk/src/hotspot/share/compiler/compileBroker.cpp:2115
#11 0x0000ffffb6a4f554 in CompileBroker::compiler_thread_loop () at /home/yangfei/openjdk-jdk/src/hotspot/share/compiler/compileBroker.cpp:1800
#12 0x0000ffffb747be0c in compiler_thread_entry (thread=0xffff581e2800, __the_thread__=0xffff581e2800)
at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:3401
#13 0x0000ffffb7477208 in JavaThread::thread_main_inner (this=0xffff581e2800) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:1917
#14 0x0000ffffb747708c in JavaThread::run (this=0xffff581e2800) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:1900
#15 0x0000ffffb7473270 in Thread::call_run (this=0xffff581e2800) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:398
#16 0x0000ffffb71e1574 in thread_native_entry (thread=0xffff581e2800) at /home/yangfei/openjdk-jdk/src/hotspot/os/linux/os_linux.cpp:792
#17 0x0000ffffb7f3edc4 in start_thread () from /lib64/libpthread.so.0
#18 0x0000ffffb7e73fd0 in thread_start () from /lib64/libc.so.6
The other use of the cmp node was created by:
#0 PhaseStringOpts::getChars (this=0xffff5c383630, kit=..., arg=0xafaf88, dst_array=0xffff58021cd8, bt=T_BYTE, end=0xaef210, final_merge=0xffff58022b18,
final_mem=0xffff58022bb0, merge_index=0) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/stringopts.cpp:1251
#1 0x0000ffffb73d72b4 in PhaseStringOpts::int_getChars (this=0xffff5c383630, kit=..., arg=0xafaf88, dst_array=0xffff58021cd8, dst_coder=0xb2d080,
start=0xffff580226f8, size=0xaebdf0) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/stringopts.cpp:1396
#2 0x0000ffffb73d93bc in PhaseStringOpts::replace_string_concat (this=0xffff5c383630, sc=0xb1bf10)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/stringopts.cpp:1932
#3 0x0000ffffb73d3cfc in PhaseStringOpts::PhaseStringOpts (this=0xffff5c383630, gvn=0xffff5c383aa8)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/stringopts.cpp:667
#4 0x0000ffffb6a39798 in Compile::inline_string_calls (this=0xffff5c384528, parse_time=true)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/compile.cpp:2026
#5 0x0000ffffb6a343d4 in Compile::Compile (this=0xffff5c384528, ci_env=0xffff5c3852d8, compiler=0xffff58002f70, target=0xb03050, osr_bci=-1,
subsume_loads=true, do_escape_analysis=true, eliminate_boxing=true, directive=0xa85fb0)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/compile.cpp:834
#6 0x0000ffffb690a508 in C2Compiler::compile_method (this=0xffff58002f70, env=0xffff5c3852d8, target=0xb03050, entry_bci=-1, directive=0xa85fb0)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/c2compiler.cpp:110
#7 0x0000ffffb6a506c8 in CompileBroker::invoke_compiler_on_method (task=0xffff58085340)
at /home/yangfei/openjdk-jdk/src/hotspot/share/compiler/compileBroker.cpp:2115
#8 0x0000ffffb6a4f554 in CompileBroker::compiler_thread_loop () at /home/yangfei/openjdk-jdk/src/hotspot/share/compiler/compileBroker.cpp:1800
#9 0x0000ffffb747be0c in compiler_thread_entry (thread=0xffff58010800, __the_thread__=0xffff58010800)
at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:3401
#10 0x0000ffffb7477208 in JavaThread::thread_main_inner (this=0xffff58010800) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:1917
#11 0x0000ffffb747708c in JavaThread::run (this=0xffff58010800) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:1900
#12 0x0000ffffb7473270 in Thread::call_run (this=0xffff58010800) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:398
#13 0x0000ffffb71e1574 in thread_native_entry (thread=0xffff58010800) at /home/yangfei/openjdk-jdk/src/hotspot/os/linux/os_linux.cpp:792
#14 0x0000ffffb7f3edc4 in start_thread () from /lib64/libpthread.so.0
#15 0x0000ffffb7e73fd0 in thread_start () from /lib64/libc.so.6
Cmp node was deleted by:
#0 PhaseIterGVN::optimize (this=0xffff5c381f28) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/phaseX.cpp:1162
#1 0x0000ffffb708a630 in PhaseIdealLoop::build_and_optimize (this=0xffff5c3812c0, mode=LoopOptsDefault)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopnode.cpp:3163
#2 0x0000ffffb6a46e58 in PhaseIdealLoop::PhaseIdealLoop (this=0xffff5c3812c0, igvn=..., mode=LoopOptsDefault)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopnode.hpp:945
#3 0x0000ffffb6a46f18 in PhaseIdealLoop::optimize (igvn=..., mode=LoopOptsDefault) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/loopnode.hpp:1020
#4 0x0000ffffb6a3abc8 in Compile::Optimize (this=0xffff5c3844a8) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/compile.cpp:2328
#5 0x0000ffffb6a3458c in Compile::Compile (this=0xffff5c3844a8, ci_env=0xffff5c385258, compiler=0xaaf7a0, target=0xb19630, osr_bci=-1, subsume_loads=true,
do_escape_analysis=true, eliminate_boxing=true, directive=0xa85fb0) at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/compile.cpp:874
#6 0x0000ffffb690a508 in C2Compiler::compile_method (this=0xaaf7a0, env=0xffff5c385258, target=0xb19630, entry_bci=-1, directive=0xa85fb0)
at /home/yangfei/openjdk-jdk/src/hotspot/share/opto/c2compiler.cpp:110
#7 0x0000ffffb6a506c8 in CompileBroker::invoke_compiler_on_method (task=0xffff58067330)
at /home/yangfei/openjdk-jdk/src/hotspot/share/compiler/compileBroker.cpp:2115
#8 0x0000ffffb6a4f554 in CompileBroker::compiler_thread_loop () at /home/yangfei/openjdk-jdk/src/hotspot/share/compiler/compileBroker.cpp:1800
#9 0x0000ffffb747be0c in compiler_thread_entry (thread=0xabd000, __the_thread__=0xabd000)
at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:3401
#10 0x0000ffffb7477208 in JavaThread::thread_main_inner (this=0xabd000) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:1917
#11 0x0000ffffb747708c in JavaThread::run (this=0xabd000) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:1900
#12 0x0000ffffb7473270 in Thread::call_run (this=0xabd000) at /home/yangfei/openjdk-jdk/src/hotspot/share/runtime/thread.cpp:398
#13 0x0000ffffb71e1574 in thread_native_entry (thread=0xabd000) at /home/yangfei/openjdk-jdk/src/hotspot/os/linux/os_linux.cpp:792
#14 0x0000ffffb7f3edc4 in start_thread () from /lib64/libpthread.so.0
#15 0x0000ffffb7e73fd0 in thread_start () from /lib64/libc.so.6
Proposed patch duplicate the cmp node if it has other users:
diff -r 5b5de2618756 src/hotspot/share/opto/loopTransform.cpp
--- a/src/hotspot/share/opto/loopTransform.cpp Mon Oct 07 17:13:59 2019 -0700
+++ b/src/hotspot/share/opto/loopTransform.cpp Wed Oct 09 15:39:42 2019 +0800
@@ -3129,6 +3129,13 @@
// We also need to replace the original limit to collapse loop exit.
Node* cmp = cl->loopexit()->cmp_node();
assert(cl->limit() == cmp->in(2), "sanity");
+ // Duplicate cmp node if it has other users
+ if (cmp->outcnt() > 1) {
+ cmp = cmp->clone();
+ cmp = phase->_igvn.register_new_node_with_optimizer(cmp);
+ BoolNode *bol = cl->loopexit()->in(CountedLoopEndNode::TestValue)->as_Bool();
+ phase->_igvn.replace_input_of(bol, 1, cmp); // put bol on worklist
+ }
phase->_igvn._worklist.push(cmp->in(2)); // put limit on worklist
phase->_igvn.replace_input_of(cmp, 2, exact_limit); // put cmp on worklist
}
Patch is currently under testing.
Thanks,
Felix
More information about the hotspot-compiler-dev
mailing list