Traverse store-load chains for POP instructions
POP instructions can be only live usages for functional parameters, e.g., when corresponding invoke is in dead code (KT-17591).
This commit is contained in:
@@ -516,8 +516,11 @@ public class MethodInliner {
|
||||
}
|
||||
}
|
||||
else if (cur.getOpcode() == Opcodes.POP) {
|
||||
LambdaInfo lambda = getLambdaIfExists(MethodInlinerUtilKt.singleOrNullInsn(StackTransformationUtilsKt.top(frame)));
|
||||
if (lambda != null) {
|
||||
SourceValue top = StackTransformationUtilsKt.top(frame);
|
||||
LambdaInfo lambdaInfo = MethodInlinerUtilKt.getLambdaIfExistsAndMarkInstructions(
|
||||
this, top, true, instructions, sources, toDelete
|
||||
);
|
||||
if (lambdaInfo != null) {
|
||||
toDelete.add(cur);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// FILE: 1.kt
|
||||
inline fun alwaysOk(s: String, fn: (String) -> String): String {
|
||||
return fn(return "OK")
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
fun box() = alwaysOk("what?") { it }
|
||||
@@ -0,0 +1,7 @@
|
||||
// FILE: 1.kt
|
||||
inline fun alwaysOk(s: String, fn: (String) -> String): String {
|
||||
try { return fn(return "fail") } finally { fn(return "OK") }
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
fun box() = alwaysOk("what?") { it }
|
||||
@@ -0,0 +1,15 @@
|
||||
// FILE: 1.kt
|
||||
inline fun alwaysOk(s: String, fn: (String) -> String): String {
|
||||
try {
|
||||
throw Exception()
|
||||
}
|
||||
catch(e: Exception) {
|
||||
fn(return "fail")
|
||||
}
|
||||
finally {
|
||||
fn(return "OK")
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
fun box() = alwaysOk("what?") { it }
|
||||
@@ -2483,6 +2483,24 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17591.kt")
|
||||
public void testKt17591() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/kt17591.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17591a.kt")
|
||||
public void testKt17591a() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/kt17591a.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17591b.kt")
|
||||
public void testKt17591b() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/kt17591b.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("mixedTypesOnStack1.kt")
|
||||
public void testMixedTypesOnStack1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/mixedTypesOnStack1.kt");
|
||||
|
||||
+18
@@ -2483,6 +2483,24 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17591.kt")
|
||||
public void testKt17591() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/kt17591.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17591a.kt")
|
||||
public void testKt17591a() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/kt17591a.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt17591b.kt")
|
||||
public void testKt17591b() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/kt17591b.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("mixedTypesOnStack1.kt")
|
||||
public void testMixedTypesOnStack1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/stackOnReturn/mixedTypesOnStack1.kt");
|
||||
|
||||
Reference in New Issue
Block a user