Remove variables with empty ranges from local vars table
As their ranges may intersect after dead code elimination that leads to VerifyError
This commit is contained in:
@@ -51,7 +51,7 @@ fun MethodNode.prepareForEmitting() {
|
||||
|
||||
// local variables with live ranges starting after last meaningful instruction lead to VerifyError
|
||||
localVariables = localVariables.filter { lv ->
|
||||
InsnSequence(lv.start, instructions.getLast()).any { insn ->
|
||||
InsnSequence(lv.start, lv.end).any { insn ->
|
||||
insn.isMeaningful
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class A {
|
||||
fun foo() {
|
||||
try {
|
||||
val a = 1
|
||||
var a = 1
|
||||
a++
|
||||
}
|
||||
catch(e : Throwable) {
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ class A {
|
||||
fun foo() {
|
||||
inlineFun ({
|
||||
var zzz = it;
|
||||
zzz++
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ class A {
|
||||
fun foo() {
|
||||
inlineFun ({ l ->
|
||||
var zzz = l;
|
||||
zzz++
|
||||
}, 11)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ class A {
|
||||
var s = 1;
|
||||
inlineFun ({
|
||||
var zzz = 2;
|
||||
zzz++
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ class A {
|
||||
var s = 0;
|
||||
inlineFun {
|
||||
var z = 1;
|
||||
z++
|
||||
|
||||
inlineFun {
|
||||
var zz2 = 2;
|
||||
zz2++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
return "OK"
|
||||
if (1 == 1) {
|
||||
val z = 2
|
||||
}
|
||||
if (3 == 3) {
|
||||
val z = 4
|
||||
}
|
||||
} finally {
|
||||
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
return "OK"
|
||||
} finally {
|
||||
if (1 == 1) {
|
||||
val z = 2
|
||||
}
|
||||
if (3 == 3) {
|
||||
val z = 4
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -2180,6 +2180,27 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/deadCodeElimination")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class DeadCodeElimination extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInDeadCodeElimination() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/deadCodeElimination"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("intersectingVariableRange.kt")
|
||||
public void testIntersectingVariableRange() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/deadCodeElimination/intersectingVariableRange.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("intersectingVariableRangeInFinally.kt")
|
||||
public void testIntersectingVariableRangeInFinally() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/deadCodeElimination/intersectingVariableRangeInFinally.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/defaultArguments")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user