Don't add unused label if variables are absent
This commit is contained in:
+3
-1
@@ -289,7 +289,9 @@ class ExpressionCodegen(
|
||||
val info = BlockInfo(data)
|
||||
// Force materialization to avoid reading from out-of-scope variables.
|
||||
return super.visitBlock(expression, info).materialized.also {
|
||||
writeLocalVariablesInTable(info, markNewLabel())
|
||||
if (info.variables.isNotEmpty()) {
|
||||
writeLocalVariablesInTable(info, markNewLabel())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.DISABLE_OPTIMIZATION
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo(a: Boolean) { if (a) { foo(a) } }
|
||||
|
||||
// method start
|
||||
// 5 L0
|
||||
|
||||
//return
|
||||
// 3 L1
|
||||
|
||||
// method end
|
||||
// 2 L2
|
||||
|
||||
// 0 L3
|
||||
@@ -1650,6 +1650,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
public void testNoUnitInstanceOnVoidFunctionCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnitInstanceOnVoidFunctionCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noUnusedLabel.kt")
|
||||
public void testNoUnusedLabel() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnusedLabel.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/enum")
|
||||
|
||||
+5
@@ -1605,6 +1605,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
public void testNoUnitInstanceOnVoidFunctionCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnitInstanceOnVoidFunctionCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noUnusedLabel.kt")
|
||||
public void testNoUnusedLabel() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/disabledOptimizations/noUnusedLabel.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/enum")
|
||||
|
||||
Reference in New Issue
Block a user