Skip to content

Commit

Permalink
8296912: C2: CreateExNode::Identity fails with assert(i < _max) faile…
Browse files Browse the repository at this point in the history
…d: oob: i=1, _max=1

Reviewed-by: rrich
Backport-of: 502fa3eeea849cfcc50436602be1654695ef4e26
  • Loading branch information
GoeLin committed Feb 8, 2023
1 parent 65180f1 commit 9d7bb60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/hotspot/share/opto/cfgnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2439,9 +2439,8 @@ Node* CreateExNode::Identity(PhaseGVN* phase) {
// exception oop through.
CallNode *call = in(1)->in(0)->as_Call();

return ( in(0)->is_CatchProj() && in(0)->in(0)->in(1) == in(1) )
? this
: call->in(TypeFunc::Parms);
return (in(0)->is_CatchProj() && in(0)->in(0)->is_Catch() &&
in(0)->in(0)->in(1) == in(1)) ? this : call->in(TypeFunc::Parms);
}

//=============================================================================
Expand Down
24 changes: 22 additions & 2 deletions test/hotspot/jtreg/compiler/c2/TestDeadDataLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

/*
* @test
* @bug 8284358
* @bug 8284358 8296912
* @summary An unreachable loop is not removed, leading to a broken graph.
* @requires vm.compiler2.enabled
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions
* -XX:CompileCommand=compileonly,*TestDeadDataLoop::test* -XX:CompileCommand=dontinline,*TestDeadDataLoop::notInlined
* -XX:CompileCommand=compileonly,*TestDeadDataLoop::test* -XX:CompileCommand=dontinline,*TestDeadDataLoop::notInlined*
* compiler.c2.TestDeadDataLoop
*/

Expand Down Expand Up @@ -210,10 +210,29 @@ static void test10() {
}
}

static long l;

static void test11(boolean never) {
float f = 1;
boolean b;
for (int i = 0; i < 5; ++i) {
b = (never || l < 0);
l = notInlined2();
if (!never) {
f += i;
}
}
l += f;
}

public static boolean notInlined() {
return false;
}

public static int notInlined2() {
return 42;
}

public static void main(String[] args) {
// Make sure classes are initialized
Integer i = 42;
Expand All @@ -228,6 +247,7 @@ public static void main(String[] args) {
test8();
test9();
test10();
test11(false);
}
}

1 comment on commit 9d7bb60

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.