Skip to content

Commit 2bdf68a

Browse files
author
Mikhael Bogdanov
committed
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
1 parent 306a982 commit 2bdf68a

File tree

7 files changed

+62
-0
lines changed

7 files changed

+62
-0
lines changed

compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class OptimizationMethodVisitor(
6666
optimizationTransformer.transform("fake", methodNode)
6767
}
6868

69+
DeadCodeEliminationMethodTransformer().transform("fake", methodNode)
70+
6971
methodNode.prepareForEmitting()
7072
}
7173

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// IGNORE_BACKEND: JVM_IR
2+
// NO_CHECK_LAMBDA_INLINING
3+
// FILE: 1.kt
4+
5+
package test
6+
7+
inline fun takeWhileSize(initialSize: Int , block: (String) -> Int) {
8+
val current = "PARAM"
9+
10+
try {
11+
if (1 >= initialSize) {
12+
try {
13+
block(current)
14+
} finally {
15+
val i = "INNER FINALLY"
16+
}
17+
} else {
18+
val e = "ELSE"
19+
}
20+
} finally {
21+
val o = "OUTER FINALLY"
22+
}
23+
}
24+
25+
// FILE: 2.kt
26+
import test.*
27+
28+
29+
fun box(): String {
30+
takeWhileSize(1) {
31+
return "OK"
32+
}
33+
34+
return "fail"
35+
}

compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrNonLocalReturnsTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NonLocalReturnsTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)