Delete dead code on last optimization step, otherwise ASM will split exception table on it.

ASM has logic that splits exception tables in MethodWriter.computeAllFrames:
     // Loop over all the basic blocks and visit the stack map frames that must be stored in the
     // StackMapTable attribute. Also replace unreachable code with NOP* ATHROW, and remove it from
     // exception handler ranges.
     ...
     firstHandler = Handler.removeRange(firstHandler, basicBlock, nextBasicBlock);
     ...
  https://gitlab.ow2.org/asm/asm/issues/317867

  #KT-28546 Fixed
This commit is contained in:
Mikhael Bogdanov
2019-01-10 13:57:39 +01:00
parent 306a982722
commit 2bdf68ad67
7 changed files with 62 additions and 0 deletions
@@ -66,6 +66,8 @@ class OptimizationMethodVisitor(
optimizationTransformer.transform("fake", methodNode)
}
DeadCodeEliminationMethodTransformer().transform("fake", methodNode)
methodNode.prepareForEmitting()
}
@@ -0,0 +1,35 @@
// IGNORE_BACKEND: JVM_IR
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
inline fun takeWhileSize(initialSize: Int , block: (String) -> Int) {
val current = "PARAM"
try {
if (1 >= initialSize) {
try {
block(current)
} finally {
val i = "INNER FINALLY"
}
} else {
val e = "ELSE"
}
} finally {
val o = "OUTER FINALLY"
}
}
// FILE: 2.kt
import test.*
fun box(): String {
takeWhileSize(1) {
return "OK"
}
return "fail"
}
@@ -2060,6 +2060,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt");
}
@TestMetadata("kt28546.kt")
public void testKt28546() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt");
}
@TestMetadata("kt6956.kt")
public void testKt6956() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt");
@@ -2060,6 +2060,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt");
}
@TestMetadata("kt28546.kt")
public void testKt28546() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt");
}
@TestMetadata("kt6956.kt")
public void testKt6956() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt");
@@ -2060,6 +2060,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt");
}
@TestMetadata("kt28546.kt")
public void testKt28546() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt");
}
@TestMetadata("kt6956.kt")
public void testKt6956() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt");
@@ -164,6 +164,11 @@ public class IrNonLocalReturnsTestGenerated extends AbstractIrNonLocalReturnsTes
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt");
}
@TestMetadata("kt28546.kt")
public void testKt28546() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt");
}
@TestMetadata("kt6956.kt")
public void testKt6956() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt");
@@ -164,6 +164,11 @@ public class NonLocalReturnsTestGenerated extends AbstractNonLocalReturnsTest {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt");
}
@TestMetadata("kt28546.kt")
public void testKt28546() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt");
}
@TestMetadata("kt6956.kt")
public void testKt6956() throws Exception {
runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt");