From 80147125699e7916da1dc4790863eca1a7b566f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Sch=C3=A4fer?= Date: Mon, 13 Jun 2022 16:13:42 +0200 Subject: [PATCH] JVM IR: Check that we generate callable references in tests --- .../runners/codegen/FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/box/directInvokeOptimization/canary.kt | 8 ++++++++ .../runners/codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../runners/codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../kotlin/codegen/LightAnalysisModeTestGenerated.java | 5 +++++ .../kotlin/js/test/JsCodegenBoxTestGenerated.java | 6 ++++++ .../kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java | 6 ++++++ .../wasm/semantics/IrCodegenBoxWasmTestGenerated.java | 5 +++++ .../konan/blackboxtest/NativeCodegenBoxTestGenerated.java | 6 ++++++ 9 files changed, 54 insertions(+) create mode 100644 compiler/testData/codegen/box/directInvokeOptimization/canary.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 68ba7e11891..b85fd26ebbd 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -15975,6 +15975,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @Test + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { diff --git a/compiler/testData/codegen/box/directInvokeOptimization/canary.kt b/compiler/testData/codegen/box/directInvokeOptimization/canary.kt new file mode 100644 index 00000000000..38a78671e62 --- /dev/null +++ b/compiler/testData/codegen/box/directInvokeOptimization/canary.kt @@ -0,0 +1,8 @@ +// The direct invoke optimization silently broke several tests. This test exists to +// ensure that we don't end up optimizing the indirect invokes that are present in the tests. +private fun id(x: String) = x + +fun box() = { "O" }.let { it() } + ::id.let { it("K") } + +// CHECK_BYTECODE_TEXT +// 2 Function[^.\n]*\.invoke diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index c1f9c644da0..b130c64aace 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -15789,6 +15789,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @Test + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 28d1e66ad84..08e86867459 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -15975,6 +15975,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @Test + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index e732d01ea26..1302b23578e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13005,6 +13005,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { runTest("compiler/testData/codegen/box/directInvokeOptimization/capturingLambda.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 48130810329..d378b36126b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -12179,6 +12179,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @Test + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 161675f22c3..fc6ef5f8466 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -12221,6 +12221,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @Test + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 79b234c277b..cb8adf587ca 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -10855,6 +10855,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { runTest("compiler/testData/codegen/box/directInvokeOptimization/capturingLambda.kt"); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index e379662a944..3e791916045 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -13225,6 +13225,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt"); } + @Test + @TestMetadata("canary.kt") + public void testCanary() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/canary.kt"); + } + @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception {