diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 5ef89efdcb6..dbfd42e696e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -18704,6 +18704,42 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index b9e53ad925c..5775a32f9b6 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -18704,6 +18704,42 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 5f0d0918f2e..6a51247950c 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -18704,6 +18704,42 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/codegen/box/fileCheck/adopted_function_reference.kt b/compiler/testData/codegen/box/fileCheck/adopted_function_reference.kt new file mode 100644 index 00000000000..cdd32f321fd --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/adopted_function_reference.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +inline fun foo(x: () -> Unit): String { + x() + return "OK" +} + +fun String.id(s: String = this, vararg xs: Int): String = s + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + // CHECK-LABEL: entry + // CHECK-NOT: call %struct.ObjHeader* @AllocInstance + // CHECK-NOT: alloca + return foo("Fail"::id) + // CHECK-LABEL: epilogue: +} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/atomics.kt b/compiler/testData/codegen/box/fileCheck/atomics.kt similarity index 72% rename from kotlin-native/backend.native/tests/filecheck/atomics.kt rename to compiler/testData/codegen/box/fileCheck/atomics.kt index 4b37ef47673..0a2a852bd5c 100644 --- a/kotlin-native/backend.native/tests/filecheck/atomics.kt +++ b/compiler/testData/codegen/box/fileCheck/atomics.kt @@ -1,17 +1,19 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + import kotlin.concurrent.* -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: define {{signext i8|i8}} @"kfun:#(){}kotlin.Byte"() +// CHECK-AAPCS-LABEL: define i8 @"kfun:#(){}kotlin.Byte"() +// CHECK-DEFAULTABI-LABEL: define signext i8 @"kfun:#(){}kotlin.Byte"() +// CHECK-WINDOWSX64-LABEL: define i8 @"kfun:#(){}kotlin.Byte"() // CHECK: load atomic i8, i8* @"kvar:byteGlobal#internal" seq_cst // CHECK-LABEL: define void @"kfun:#(kotlin.Byte){}"(i8 // CHECK: store atomic i8 %{{[0-9]+}}, i8* @"kvar:byteGlobal#internal" seq_cst @Volatile var byteGlobal: Byte = 42 -// CHECK-LABEL: define {{signext i16|i16}} @"kfun:#(){}kotlin.Short"() +// CHECK-AAPCS-LABEL: define i16 @"kfun:#(){}kotlin.Short"() +// CHECK-DEFAULTABI-LABEL: define signext i16 @"kfun:#(){}kotlin.Short"() +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#(){}kotlin.Short"() // CHECK: load atomic i16, i16* @"kvar:shortGlobal#internal" seq_cst // CHECK-LABEL: define void @"kfun:#(kotlin.Short){}"(i16 // CHECK: store atomic i16 %{{[0-9]+}}, i16* @"kvar:shortGlobal#internal" seq_cst @@ -29,7 +31,9 @@ import kotlin.concurrent.* // CHECK: store atomic i64 %{{[0-9]+}}, i64* @"kvar:longGlobal#internal" seq_cst @Volatile var longGlobal: Long = 42 -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#(){}kotlin.Boolean"() +// CHECK-AAPCS-LABEL: define i1 @"kfun:#(){}kotlin.Boolean"() +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#(){}kotlin.Boolean"() +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#(){}kotlin.Boolean"() // CHECK: load atomic i8, i8* @"kvar:booleanGlobal#internal" seq_cst // CHECK-LABEL: define void @"kfun:#(kotlin.Boolean){}"(i1 // CHECK: store atomic i8 %{{[0-9]+}}, i8* @"kvar:booleanGlobal#internal" seq_cst @@ -39,23 +43,31 @@ import kotlin.concurrent.* fun byteGlobal_getField() = byteGlobal fun byteGlobal_setField() { byteGlobal = 0 } -// CHECK-LABEL: define {{signext i8|i8}} @"kfun:#byteGlobal_getAndSetField(){}kotlin.Byte"() +// CHECK-AAPCS-LABEL: define i8 @"kfun:#byteGlobal_getAndSetField(){}kotlin.Byte"() +// CHECK-DEFAULTABI-LABEL: define signext i8 @"kfun:#byteGlobal_getAndSetField(){}kotlin.Byte"() +// CHECK-WINDOWSX64-LABEL: define i8 @"kfun:#byteGlobal_getAndSetField(){}kotlin.Byte"() // CHECK: atomicrmw xchg i8* @"kvar:byteGlobal#internal", i8 0 seq_cst @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun byteGlobal_getAndSetField() = ::byteGlobal.getAndSetField(0.toByte()) -// CHECK-LABEL: define {{signext i8|i8}} @"kfun:#byteGlobal_getAndAddField(){}kotlin.Byte"() +// CHECK-AAPCS-LABEL: define i8 @"kfun:#byteGlobal_getAndAddField(){}kotlin.Byte"() +// CHECK-DEFAULTABI-LABEL: define signext i8 @"kfun:#byteGlobal_getAndAddField(){}kotlin.Byte"() +// CHECK-WINDOWSX64-LABEL: define i8 @"kfun:#byteGlobal_getAndAddField(){}kotlin.Byte"() // CHECK: atomicrmw add i8* @"kvar:byteGlobal#internal", i8 0 seq_cst @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun byteGlobal_getAndAddField() = ::byteGlobal.getAndAddField(0.toByte()) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#byteGlobal_compareAndSetField(){}kotlin.Boolean"() +// CHECK-AAPCS-LABEL: define i1 @"kfun:#byteGlobal_compareAndSetField(){}kotlin.Boolean"() +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#byteGlobal_compareAndSetField(){}kotlin.Boolean"() +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#byteGlobal_compareAndSetField(){}kotlin.Boolean"() // CHECK: cmpxchg i8* @"kvar:byteGlobal#internal", i8 0, i8 1 seq_cst seq_cst // CHECK: extractvalue { i8, i1 } %{{[0-9]+}}, 1 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun byteGlobal_compareAndSetField() = ::byteGlobal.compareAndSetField(0.toByte(), 1.toByte()) -// CHECK-LABEL: define {{signext i8|i8}} @"kfun:#byteGlobal_compareAndExchangeField(){}kotlin.Byte"() +// CHECK-AAPCS-LABEL: define i8 @"kfun:#byteGlobal_compareAndExchangeField(){}kotlin.Byte"() +// CHECK-DEFAULTABI-LABEL: define signext i8 @"kfun:#byteGlobal_compareAndExchangeField(){}kotlin.Byte"() +// CHECK-WINDOWSX64-LABEL: define i8 @"kfun:#byteGlobal_compareAndExchangeField(){}kotlin.Byte"() // CHECK: cmpxchg i8* @"kvar:byteGlobal#internal", i8 0, i8 1 seq_cst seq_cst // CHECK: extractvalue { i8, i1 } %{{[0-9]+}}, 0 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") @@ -65,23 +77,31 @@ fun byteGlobal_compareAndExchangeField() = ::byteGlobal.compareAndExchangeField( fun shortGlobal_getField() = shortGlobal fun shortGlobal_setField() { shortGlobal = 0 } -// CHECK-LABEL: define {{signext i16|i16}} @"kfun:#shortGlobal_getAndSetField(){} +// CHECK-AAPCS-LABEL: define i16 @"kfun:#shortGlobal_getAndSetField(){} +// CHECK-DEFAULTABI-LABEL: define signext i16 @"kfun:#shortGlobal_getAndSetField(){} +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#shortGlobal_getAndSetField(){} // CHECK: atomicrmw xchg i16* @"kvar:shortGlobal#internal", i16 0 seq_cst @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun shortGlobal_getAndSetField() = ::shortGlobal.getAndSetField(0.toShort()) -// CHECK-LABEL: define {{signext i16|i16}} @"kfun:#shortGlobal_getAndAddField(){} +// CHECK-AAPCS-LABEL: define i16 @"kfun:#shortGlobal_getAndAddField(){} +// CHECK-DEFAULTABI-LABEL: define signext i16 @"kfun:#shortGlobal_getAndAddField(){} +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#shortGlobal_getAndAddField(){} // CHECK: atomicrmw add i16* @"kvar:shortGlobal#internal", i16 0 seq_cst @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun shortGlobal_getAndAddField() = ::shortGlobal.getAndAddField(0.toShort()) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#shortGlobal_compareAndSetField(){} +// CHECK-AAPCS-LABEL: define i1 @"kfun:#shortGlobal_compareAndSetField(){} +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#shortGlobal_compareAndSetField(){} +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#shortGlobal_compareAndSetField(){} // CHECK: cmpxchg i16* @"kvar:shortGlobal#internal", i16 0, i16 1 seq_cst seq_cst // CHECK: extractvalue { i16, i1 } %{{[0-9]+}}, 1 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun shortGlobal_compareAndSetField() = ::shortGlobal.compareAndSetField(0.toShort(), 1.toShort()) -// CHECK-LABEL: define {{signext i16|i16}} @"kfun:#shortGlobal_compareAndExchangeField(){} +// CHECK-AAPCS-LABEL: define i16 @"kfun:#shortGlobal_compareAndExchangeField(){} +// CHECK-DEFAULTABI-LABEL: define signext i16 @"kfun:#shortGlobal_compareAndExchangeField(){} +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#shortGlobal_compareAndExchangeField(){} // CHECK: cmpxchg i16* @"kvar:shortGlobal#internal", i16 0, i16 1 seq_cst seq_cst // CHECK: extractvalue { i16, i1 } %{{[0-9]+}}, 0 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") @@ -101,7 +121,9 @@ fun intGlobal_getAndSetField() = ::intGlobal.getAndSetField(0) @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun intGlobal_getAndAddField() = ::intGlobal.getAndAddField(0) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#intGlobal_compareAndSetField(){} +// CHECK-AAPCS-LABEL: define i1 @"kfun:#intGlobal_compareAndSetField(){} +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#intGlobal_compareAndSetField(){} +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#intGlobal_compareAndSetField(){} // CHECK: cmpxchg i32* @"kvar:intGlobal#internal", i32 0, i32 1 seq_cst seq_cst // CHECK: extractvalue { i32, i1 } %{{[0-9]+}}, 1 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") @@ -127,7 +149,9 @@ fun longGlobal_getAndSetField() = ::longGlobal.getAndSetField(0L) @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun longGlobal_getAndAddField() = ::longGlobal.getAndAddField(0L) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#longGlobal_compareAndSetField(){} +// CHECK-AAPCS-LABEL: define i1 @"kfun:#longGlobal_compareAndSetField(){} +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#longGlobal_compareAndSetField(){} +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#longGlobal_compareAndSetField(){} // CHECK: cmpxchg i64* @"kvar:longGlobal#internal", i64 0, i64 1 seq_cst seq_cst // CHECK: extractvalue { i64, i1 } %{{[0-9]+}}, 1 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") @@ -143,18 +167,24 @@ fun longGlobal_compareAndExchangeField() = ::longGlobal.compareAndExchangeField( fun booleanGlobal_getField() = booleanGlobal fun booleanGlobal_setField() { booleanGlobal = false } -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#booleanGlobal_getAndSetField(){}kotlin.Boolean" +// CHECK-AAPCS-LABEL: define i1 @"kfun:#booleanGlobal_getAndSetField(){}kotlin.Boolean" +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#booleanGlobal_getAndSetField(){}kotlin.Boolean" +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#booleanGlobal_getAndSetField(){}kotlin.Boolean" // CHECK: atomicrmw xchg i8* @"kvar:booleanGlobal#internal", i8 %{{[0-9]+}} seq_cst @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun booleanGlobal_getAndSetField() = ::booleanGlobal.getAndSetField(false) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#booleanGlobal_compareAndSetField(){} +// CHECK-AAPCS-LABEL: define i1 @"kfun:#booleanGlobal_compareAndSetField(){} +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#booleanGlobal_compareAndSetField(){} +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#booleanGlobal_compareAndSetField(){} // CHECK: cmpxchg i8* @"kvar:booleanGlobal#internal", i8 %{{[0-9]+}}, i8 %{{[0-9]+}} seq_cst seq_cst // CHECK: extractvalue { i8, i1 } %{{[0-9]+}}, 1 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun booleanGlobal_compareAndSetField() = ::booleanGlobal.compareAndSetField(false, true) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#booleanGlobal_compareAndExchangeField(){} +// CHECK-AAPCS-LABEL: define i1 @"kfun:#booleanGlobal_compareAndExchangeField(){} +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#booleanGlobal_compareAndExchangeField(){} +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#booleanGlobal_compareAndExchangeField(){} // CHECK: cmpxchg i8* @"kvar:booleanGlobal#internal", i8 %{{[0-9]+}}, i8 %{{[0-9]+}} seq_cst seq_cst // CHECK: extractvalue { i8, i1 } %{{[0-9]+}}, 0 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") @@ -194,7 +224,9 @@ fun intArr_getAndAdd() = intArr.getAndAdd(0, 1) @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun intArr_compareAndExchange() = intArr.compareAndExchange(0, 1, 2) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#intArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-AAPCS-LABEL: define i1 @"kfun:#intArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#intArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#intArr_compareAndSet(){}kotlin.Boolean"() // CHECK: call i32* @Kotlin_intArrayGetElementAddress(%struct.ObjHeader* %{{[0-9]+}}, i32 0) // CHECK: cmpxchg i32* %{{[0-9]+}}, i32 1, i32 2 seq_cst seq_cst // CHECK: extractvalue { i32, i1 } %{{[0-9]+}}, 1 @@ -235,7 +267,9 @@ fun longArr_getAndAdd() = longArr.getAndAdd(0, 1L) @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun longArr_compareAndExchange() = longArr.compareAndExchange(0, 1L, 2L) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#longArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-AAPCS-LABEL: define i1 @"kfun:#longArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#longArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#longArr_compareAndSet(){}kotlin.Boolean"() // CHECK: call i64* @Kotlin_longArrayGetElementAddress(%struct.ObjHeader* %{{[0-9]+}}, i32 0) // CHECK: cmpxchg i64* %{{[0-9]+}}, i64 1, i64 2 seq_cst seq_cst // CHECK: extractvalue { i64, i1 } %{{[0-9]+}}, 1 @@ -269,13 +303,18 @@ fun refArr_getAndSet() = refArr.getAndSet(0, null) @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun refArr_compareAndExchange() = refArr.compareAndExchange(0, null, null) -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:#refArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-AAPCS-LABEL: define i1 @"kfun:#refArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#refArr_compareAndSet(){}kotlin.Boolean"() +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#refArr_compareAndSet(){}kotlin.Boolean"() // CHECK: call %struct.ObjHeader** @Kotlin_arrayGetElementAddress(%struct.ObjHeader* %{{[0-9]+}}, i32 0) -// CHECK: call {{zeroext i1|i1}} @CompareAndSetVolatileHeapRef(%struct.ObjHeader** %{{[0-9]+}}, %struct.ObjHeader* null, %struct.ObjHeader* null) +// CHECK-AAPCS: call i1 @CompareAndSetVolatileHeapRef(%struct.ObjHeader** %{{[0-9]+}}, %struct.ObjHeader* null, %struct.ObjHeader* null) +// CHECK-DEFAULTABI: call zeroext i1 @CompareAndSetVolatileHeapRef(%struct.ObjHeader** %{{[0-9]+}}, %struct.ObjHeader* null, %struct.ObjHeader* null) +// CHECK-WINDOWSX64: call zeroext i1 @CompareAndSetVolatileHeapRef(%struct.ObjHeader** %{{[0-9]+}}, %struct.ObjHeader* null, %struct.ObjHeader* null) @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") fun refArr_compareAndSet() = refArr.compareAndSet(0, null, null) -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { byteGlobal_getField() byteGlobal_setField() byteGlobal_getAndSetField() @@ -329,4 +368,5 @@ fun main() { refArr_getAndSet() refArr_compareAndSet() refArr_compareAndExchange() + return "OK" } diff --git a/kotlin-native/backend.native/tests/filecheck/bce.kt b/compiler/testData/codegen/box/fileCheck/bce.kt similarity index 97% rename from kotlin-native/backend.native/tests/filecheck/bce.kt rename to compiler/testData/codegen/box/fileCheck/bce.kt index dc2ae07d908..bf243a709d8 100644 --- a/kotlin-native/backend.native/tests/filecheck/bce.kt +++ b/compiler/testData/codegen/box/fileCheck/bce.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs // CHECK-LABEL: define void @"kfun:#forEachIndicies(){}"() fun forEachIndicies() { @@ -310,8 +308,9 @@ fun chainedReceivers() { } // CHECK-LABEL: {{^}}epilogue: +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" @ExperimentalStdlibApi -fun main() { +fun box(): String { forEachIndicies() forUntilSize() forRangeUntilSize() @@ -334,4 +333,6 @@ fun main() { topLevelProperty() childClassWithFakeOverride() chainedReceivers() + + return "OK" } \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/constants_merge.kt b/compiler/testData/codegen/box/fileCheck/constants_merge.kt similarity index 92% rename from kotlin-native/backend.native/tests/filecheck/constants_merge.kt rename to compiler/testData/codegen/box/fileCheck/constants_merge.kt index 087d828b5f0..8b18d040240 100644 --- a/kotlin-native/backend.native/tests/filecheck/constants_merge.kt +++ b/compiler/testData/codegen/box/fileCheck/constants_merge.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs import kotlin.reflect.* @@ -14,7 +12,8 @@ import kotlin.reflect.* // CHECK: internal unnamed_addr constant { %struct.ObjHeader, %struct.ObjHeader*, %struct.ObjHeader*, i1 } { %struct.ObjHeader { %struct.TypeInfo* {{.*}} }, %struct.ObjHeader* getelementptr inbounds ({ %struct.ObjHeader, i8* }, { %struct.ObjHeader, i8* }* [[REG_FOR_CLASSIFIER_FIELD:@[0-9]+]], i32 0, i32 0), %struct.ObjHeader* getelementptr inbounds ({ %struct.ObjHeader, %struct.ObjHeader*, %struct.ObjHeader* }, { %struct.ObjHeader, %struct.ObjHeader*, %struct.ObjHeader* }* [[REG_FOR_ARGUMENTS_FIELD:@[0-9]+]], i32 0, i32 0), i1 false } // CHECK-NOT: internal unnamed_addr constant { %struct.ObjHeader, %struct.ObjHeader*, %struct.ObjHeader*, i1 } { %struct.ObjHeader { %struct.TypeInfo* {{.*}} }, %struct.ObjHeader* getelementptr inbounds ({ %struct.ObjHeader, i8* }, { %struct.ObjHeader, i8* }* [[REG_FOR_CLASSIFIER_FIELD]], i32 0, i32 0), %struct.ObjHeader* getelementptr inbounds ({ %struct.ObjHeader, %struct.ObjHeader*, %struct.ObjHeader* }, { %struct.ObjHeader, %struct.ObjHeader*, %struct.ObjHeader* }* [[REG_FOR_ARGUMENTS_FIELD]], i32 0, i32 0), i1 false } -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { println(1024) println(1024) @@ -23,4 +22,5 @@ fun main() { println(typeOf>()) println(typeOf>()) -} \ No newline at end of file + return "OK" +} diff --git a/kotlin-native/backend.native/tests/filecheck/default_parameters_dont_box.kt b/compiler/testData/codegen/box/fileCheck/default_parameters_dont_box.kt similarity index 69% rename from kotlin-native/backend.native/tests/filecheck/default_parameters_dont_box.kt rename to compiler/testData/codegen/box/fileCheck/default_parameters_dont_box.kt index 89cedb8dcdc..c40e6db4a90 100644 --- a/kotlin-native/backend.native/tests/filecheck/default_parameters_dont_box.kt +++ b/compiler/testData/codegen/box/fileCheck/default_parameters_dont_box.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs value class A(val i: Int) value class B(val a: A) @@ -12,8 +10,8 @@ fun defaultA(a: A = A(1), aa: A = A(1)) = a.i fun defaultB(b: B = B(A(1)), bb: B = B(A(1))) = b.a.i fun defaultC(c: C = C("1"), cc: C = C("1")) = c.s -// CHECK-LABEL: "kfun:#main(){}" -fun main(){ +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { // CHECK-LABEL: entry // CHECK-NOT: // CHECK-NOT: @@ -32,5 +30,6 @@ fun main(){ defaultA(A(1), A(1)) defaultB(B(A(1)), B(A(1))) defaultC(C("1"), C("1")) - // CHECK-LABEL: epilogue + // CHECK-LABEL: epilogue: + return "OK" } \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/enum_when.kt b/compiler/testData/codegen/box/fileCheck/enum_when.kt similarity index 60% rename from kotlin-native/backend.native/tests/filecheck/enum_when.kt rename to compiler/testData/codegen/box/fileCheck/enum_when.kt index d7a7259284c..5d5458f1f41 100644 --- a/kotlin-native/backend.native/tests/filecheck/enum_when.kt +++ b/compiler/testData/codegen/box/fileCheck/enum_when.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs enum class COLOR { RED, @@ -9,24 +7,22 @@ enum class COLOR { BLUE } -// CHECK-LABEL: "kfun:#main(){}" -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { for (i in COLOR.values()) { - // CHECK: = call i32 @"kfun:kotlin.Enum#(){}kotlin.Int"( + // CHECK-DEBUG: = call i32 @"kfun:kotlin.Enum#(){}kotlin.Int"( // We inline .ordinal property access in case of opt build, so check direct field load instead. // CHECK-OPT: getelementptr inbounds %"kclassbody:kotlin.Enum#internal", %"kclassbody:kotlin.Enum#internal"* %{{[0-9a-z]*}}, i32 0, i32 2 print(when (i) { // we can't check the register is same, because it can be saved on stack and loaded back // CHECK: icmp eq i32 %{{[0-9a-z]*}}, 0 - // CHECK-OPT: icmp eq i32 %{{[0-9a-z]*}}, 0 COLOR.RED -> 0xff0000 // CHECK: icmp eq i32 %{{[0-9a-z]*}}, 1 - // CHECK-OPT: icmp eq i32 %{{[0-9a-z]*}}, 1 COLOR.GREEN -> 0x00ff00 // CHECK: icmp eq i32 %{{[0-9a-z]*}}, 2 - // CHECK-OPT: icmp eq i32 %{{[0-9a-z]*}}, 2 COLOR.BLUE -> 0x0000ff }) } // CHECK-LABEL: epilogue: + return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/fileCheck/escape_analysis.kt b/compiler/testData/codegen/box/fileCheck/escape_analysis.kt new file mode 100644 index 00000000000..d3ba93f4a57 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/escape_analysis.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +class A(val x: Int) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + // CHECK-DEBUG: call %struct.ObjHeader* @AllocInstance + // CHECK-OPT: alloca %"kclassbody:A#internal" + val a = A(5) + println(a.x) +// CHECK-LABEL: epilogue: + return "OK" +} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/force_arm_instruction_set.kt b/compiler/testData/codegen/box/fileCheck/force_arm_instruction_set.kt similarity index 65% rename from kotlin-native/backend.native/tests/filecheck/force_arm_instruction_set.kt rename to compiler/testData/codegen/box/fileCheck/force_arm_instruction_set.kt index d48719b83dc..f4973e21792 100644 --- a/kotlin-native/backend.native/tests/filecheck/force_arm_instruction_set.kt +++ b/compiler/testData/codegen/box/fileCheck/force_arm_instruction_set.kt @@ -1,7 +1,8 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE + +// Perform check after optimization pipeline because +// LLVM might infer attributes. +// FILECHECK_STAGE: LTOBitcodeOptimization // NB: This is not a good test. // What we actually want to check is that Kotlin/Native compiler is able to produce "big" @@ -11,10 +12,8 @@ // Instead, here we check that none of the module's functions are compiled in the Thumb mode. // BL instructions in thumb mode have smaller ranges which causes "relocation out of range" failure. -// CHECK: target triple = "armv7k-apple-watchos{{.+}}" +// CHECK-WATCHOS_ARM32: target triple = "armv7k-apple-watchos2{{.+}}" -fun main() { - println("hello") -} +fun box() = "OK" // CHECK-NOT: attributes #{{[0-9]+}} = { {{.+}}+thumb-mode{{.+}} } \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/function_attributes_at_callsite.kt b/compiler/testData/codegen/box/fileCheck/function_attributes_at_callsite.kt similarity index 65% rename from kotlin-native/backend.native/tests/filecheck/function_attributes_at_callsite.kt rename to compiler/testData/codegen/box/fileCheck/function_attributes_at_callsite.kt index 3596041d663..ac2b2862a0b 100644 --- a/kotlin-native/backend.native/tests/filecheck/function_attributes_at_callsite.kt +++ b/compiler/testData/codegen/box/fileCheck/function_attributes_at_callsite.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs // CHECK: declare void @ThrowException(%struct.ObjHeader*) #[[THROW_EXCEPTION_DECLARATION_ATTRIBUTES:[0-9]+]] @@ -11,10 +9,16 @@ fun flameThrower(): Nothing { throw Throwable("🔥") } -// CHECK-LABEL: void @"kfun:#main(){}"() -fun main() { - // CHECK: call void @"kfun:#flameThrower(){}kotlin.Nothing"() #[[FLAME_THROWER_CALLSITE_ATTRIBUTES:[0-9]+]] - flameThrower() +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + + // CHECK: invoke void @"kfun:#flameThrower(){}kotlin.Nothing"() #[[FLAME_THROWER_CALLSITE_ATTRIBUTES:[0-9]+]] + try { + flameThrower() + } catch (e: Throwable) { + return "OK" + } + return "FAIL: Uncaught exception" } // CHECK-DAG: attributes #[[THROW_EXCEPTION_DECLARATION_ATTRIBUTES]] = {{{.*}}noreturn{{.*}}} diff --git a/kotlin-native/backend.native/tests/filecheck/generic_function_references.kt b/compiler/testData/codegen/box/fileCheck/generic_function_references.kt similarity index 69% rename from kotlin-native/backend.native/tests/filecheck/generic_function_references.kt rename to compiler/testData/codegen/box/fileCheck/generic_function_references.kt index 54dbc58cc0c..1e00ec44b74 100644 --- a/kotlin-native/backend.native/tests/filecheck/generic_function_references.kt +++ b/compiler/testData/codegen/box/fileCheck/generic_function_references.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs import kotlin.reflect.KFunction2 @@ -49,7 +47,8 @@ fun bar() { println(ref) } -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { println(stringifyArray(arrayOf(N(2), N(14)))) println(stringifyIntArray(arrayOf(1, 2, 3))) @@ -58,6 +57,7 @@ fun main() { val ref: KFunction2 = ::foo // $foo$FUNCTION_REFERENCE$5 println(ref) + return "OK" } // CHECK-LABEL: define internal i32 @"kfun:$stringifyArray$lambda$0$FUNCTION_REFERENCE$0.invoke#internal" @@ -68,18 +68,21 @@ fun main() { // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:$stringifyArray$lambda$0$FUNCTION_REFERENCE$0.$invoke(kotlin.Array<1:0>){}kotlin.Int#internal" // CHECK-SAME: (%struct.ObjHeader* [[this:%[0-9]+]], %struct.ObjHeader* [[array:%[0-9]+]], %struct.ObjHeader** {{%[0-9]+}}) -// CHECK: call i32 @"kfun:$stringifyArray$lambda$0$FUNCTION_REFERENCE$0.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]]) +// CHECK-OPT: call i32 @"kfun:$stringifyArray$lambda$0$FUNCTION_REFERENCE$0.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]]) +// CHECK-DEBUG: call i32 @"kfun:$stringifyArray$lambda$0$FUNCTION_REFERENCE$0.invoke#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}) // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:$get$FUNCTION_REFERENCE$1.invoke#internal" // CHECK-SAME: (%struct.ObjHeader* [[this:%[0-9]+]], %struct.ObjHeader* [[array:%[0-9]+]], i32 [[index:%[0-9]+]], %struct.ObjHeader** [[ret:%[0-9]+]]) -// CHECK: call %struct.ObjHeader* @Kotlin_Array_get(%struct.ObjHeader* [[array]], i32 [[index]], %struct.ObjHeader** [[ret]]) +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_Array_get(%struct.ObjHeader* [[array]], i32 [[index]], %struct.ObjHeader** [[ret]]) +// CHECK-DEBUG: call %struct.ObjHeader* @Kotlin_Array_get(%struct.ObjHeader* {{%[0-9]+}}, i32 {{%[0-9]+}}, %struct.ObjHeader** {{%[0-9]+}}) // CHECK-LABEL: define internal void @"kfun:$get$FUNCTION_REFERENCE$1.#internal" // CHECK-SAME: (%struct.ObjHeader* {{%[0-9]+}}) // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:$get$FUNCTION_REFERENCE$1.$invoke(kotlin.Array<*>;kotlin.Int){}kotlin.Any?#internal" // CHECK-SAME: (%struct.ObjHeader* [[this:%[0-9]+]], %struct.ObjHeader* [[array:%[0-9]+]], %struct.ObjHeader* [[boxedIndex:%[0-9]+]], %struct.ObjHeader** [[ret:%[0-9]+]]) -// CHECK: call %struct.ObjHeader* @"kfun:$get$FUNCTION_REFERENCE$1.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]], i32 {{%[0-9]+}}, %struct.ObjHeader** [[ret]]) +// CHECK-OPT: call %struct.ObjHeader* @"kfun:$get$FUNCTION_REFERENCE$1.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]], i32 {{%[0-9]+}}, %struct.ObjHeader** [[ret]]) +// CHECK-DEBUG: call %struct.ObjHeader* @"kfun:$get$FUNCTION_REFERENCE$1.invoke#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}, i32 {{%[0-9]+}}, %struct.ObjHeader** {{%[0-9]+}}) // CHECK-LABEL: define internal i32 @"kfun:$stringifyIntArray$lambda$1$FUNCTION_REFERENCE$2.invoke#internal" // CHECK-SAME: (%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}) @@ -89,7 +92,8 @@ fun main() { // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:$stringifyIntArray$lambda$1$FUNCTION_REFERENCE$2.$invoke(kotlin.Array){}kotlin.Int#internal" // CHECK-SAME: (%struct.ObjHeader* [[this:%[0-9]+]], %struct.ObjHeader* [[array:%[0-9]+]], %struct.ObjHeader** {{%[0-9]+}}) -// CHECK: call i32 @"kfun:$stringifyIntArray$lambda$1$FUNCTION_REFERENCE$2.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]]) +// CHECK-OPT: call i32 @"kfun:$stringifyIntArray$lambda$1$FUNCTION_REFERENCE$2.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]]) +// CHECK-DEBUG: call i32 @"kfun:$stringifyIntArray$lambda$1$FUNCTION_REFERENCE$2.invoke#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}) // CHECK-LABEL: define internal i32 @"kfun:$get$FUNCTION_REFERENCE$3.invoke#internal" // CHECK-SAME: (%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}, i32 {{%[0-9]+}}) @@ -99,18 +103,21 @@ fun main() { // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:$get$FUNCTION_REFERENCE$3.$invoke(kotlin.Array;kotlin.Int){}kotlin.Int#internal" // CHECK-SAME: (%struct.ObjHeader* [[this:%[0-9]+]], %struct.ObjHeader* [[array:%[0-9]+]], %struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader** {{%[0-9]+}}) -// CHECK: call i32 @"kfun:$get$FUNCTION_REFERENCE$3.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]], i32 {{%[0-9]+}}) +// CHECK-OPT: call i32 @"kfun:$get$FUNCTION_REFERENCE$3.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[array]], i32 {{%[0-9]+}}) +// CHECK-DEBUG: call i32 @"kfun:$get$FUNCTION_REFERENCE$3.invoke#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}, i32 {{%[0-9]+}}) // CHECK-LABEL: define internal void @"kfun:$foo$FUNCTION_REFERENCE$4.invoke#internal" // CHECK-SAME: (%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* [[p1:%[0-9]+]], %struct.ObjHeader* [[p2:%[0-9]+]]) -// CHECK: call void @"kfun:#foo(0:0;0:1){0\C2\A7;1\C2\A7}"(%struct.ObjHeader* [[p1]], %struct.ObjHeader* [[p2]]) +// CHECK-OPT: call void @"kfun:#foo(0:0;0:1){0\C2\A7;1\C2\A7}"(%struct.ObjHeader* [[p1]], %struct.ObjHeader* [[p2]]) +// CHECK-DEBUG: call void @"kfun:#foo(0:0;0:1){0\C2\A7;1\C2\A7}"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}) // CHECK-LABEL: define internal void @"kfun:$foo$FUNCTION_REFERENCE$4.#internal" // CHECK-SAME: (%struct.ObjHeader* {{%[0-9]+}}) // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:$foo$FUNCTION_REFERENCE$4.$invoke(1:0;1:0){}#internal" // CHECK-SAME: (%struct.ObjHeader* [[this:%[0-9]+]], %struct.ObjHeader* [[p1:%[0-9]+]], %struct.ObjHeader* [[p2:%[0-9]+]], %struct.ObjHeader** {{%[0-9]+}}) -// CHECK: call void @"kfun:$foo$FUNCTION_REFERENCE$4.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[p1]], %struct.ObjHeader* [[p2]]) +// CHECK-OPT: call void @"kfun:$foo$FUNCTION_REFERENCE$4.invoke#internal"(%struct.ObjHeader* [[this]], %struct.ObjHeader* [[p1]], %struct.ObjHeader* [[p2]]) +// CHECK-DEBUG: call void @"kfun:$foo$FUNCTION_REFERENCE$4.invoke#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}) // CHECK-LABEL: define internal void @"kfun:$foo$FUNCTION_REFERENCE$5.invoke#internal" // CHECK-SAME: (%struct.ObjHeader* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}}) @@ -121,4 +128,5 @@ fun main() { // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:$foo$FUNCTION_REFERENCE$5.$invoke(kotlin.Int;kotlin.Int){}#internal" // CHECK-SAME: (%struct.ObjHeader* [[this:%[0-9]+]], %struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader** {{%[0-9]+}}) -// CHECK: call void @"kfun:$foo$FUNCTION_REFERENCE$5.invoke#internal"(%struct.ObjHeader* [[this]], i32 {{%[0-9]+}}, i32 {{%[0-9]+}}) +// CHECK-OPT: call void @"kfun:$foo$FUNCTION_REFERENCE$5.invoke#internal"(%struct.ObjHeader* [[this]], i32 {{%[0-9]+}}, i32 {{%[0-9]+}}) +// CHECK-DEBUG: call void @"kfun:$foo$FUNCTION_REFERENCE$5.invoke#internal"(%struct.ObjHeader* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}}) diff --git a/kotlin-native/backend.native/tests/filecheck/intrinsics.kt b/compiler/testData/codegen/box/fileCheck/intrinsics.kt similarity index 54% rename from kotlin-native/backend.native/tests/filecheck/intrinsics.kt rename to compiler/testData/codegen/box/fileCheck/intrinsics.kt index ab00fa8e161..480bb617f9e 100644 --- a/kotlin-native/backend.native/tests/filecheck/intrinsics.kt +++ b/compiler/testData/codegen/box/fileCheck/intrinsics.kt @@ -1,25 +1,26 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs // CHECK-LABEL: "kfun:#and(kotlin.Int;kotlin.Int){}kotlin.Int" fun and(a: Int, b: Int): Int { // CHECK: and {{.*}}, {{.*}} return a and b -// CHECK-LABEL: epilogue +// CHECK-LABEL: epilogue: } // CHECK-LABEL: "kfun:#ieee754(kotlin.Float;kotlin.Float){}kotlin.Boolean" fun ieee754(a: Float, b: Float): Boolean { // CHECK: fcmp oeq float {{.*}}, {{.*}} return a == b -// CHECK-LABEL: epilogue +// CHECK-LABEL: epilogue: } -// CHECK-LABEL: "kfun:#main(){}" -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { val x = and(1, 2) val y = ieee754(0.0f, 1.0f) -// CHECK-LABEL: epilogue +// CHECK-LABEL: epilogue: + return if (x == 0 && !y) + "OK" + else "FAIL x=$x y=$y" } diff --git a/compiler/testData/codegen/box/fileCheck/kt49847_class.kt b/compiler/testData/codegen/box/fileCheck/kt49847_class.kt new file mode 100644 index 00000000000..4c224fd82b7 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt49847_class.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +class C { + fun foo(x: Int) = x +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-OPT-NOT: Int-box +// CHECK-DEBUG: Int-box +// CHECK-NOT: Int-unbox +// CHECK-LABEL: epilogue: +fun box(): String { + val c = C() + val fooref = c::foo + val result = fooref(42) + return if( result == 42) + "OK" + else + "FAIL: $result" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt49847_generic.kt b/compiler/testData/codegen/box/fileCheck/kt49847_generic.kt new file mode 100644 index 00000000000..e2a0268e351 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt49847_generic.kt @@ -0,0 +1,20 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +class C { + fun foo(x: T) = x +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-NOT: Int-box +// CHECK-OPT-NOT: Int-unbox +// CHECK-DEBUG: Int-unbox +// CHECK-LABEL: epilogue: +fun box(): String { + val c = C() + val fooref = c::foo + return if (fooref(42) == 42) + "OK" + else + "FAIL" +} diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_generic_receiver.kt b/compiler/testData/codegen/box/fileCheck/kt49847_generic_receiver.kt similarity index 59% rename from kotlin-native/backend.native/tests/filecheck/kt49847_generic_receiver.kt rename to compiler/testData/codegen/box/fileCheck/kt49847_generic_receiver.kt index 521291e1630..a17cb8da2b4 100644 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_generic_receiver.kt +++ b/compiler/testData/codegen/box/fileCheck/kt49847_generic_receiver.kt @@ -1,24 +1,25 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs fun T.foo() { println(this) } // CHECK-LABEL: define void @"kfun:#bar(0:0){0\C2\A7}" // CHECK-SAME: (%struct.ObjHeader* [[x:%[0-9]+]]) fun bar(x: BarTP) { - // CHECK: call void @"kfun:$foo$FUNCTION_REFERENCE$0.#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* [[x]]) + // CHECK-OPT: call void @"kfun:$foo$FUNCTION_REFERENCE$0.#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* [[x]]) + // CHECK-DEBUG: call void @"kfun:$foo$FUNCTION_REFERENCE$0.#internal"(%struct.ObjHeader* {{%[0-9]+}}, %struct.ObjHeader* {{%[0-9]+}}) println(x::foo) } -// CHECK-LABEL: define void @"kfun:#main(){}" -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { // CHECK: call void @"kfun:$foo$FUNCTION_REFERENCE$1.#internal"(%struct.ObjHeader* {{%[0-9]+}}, i32 5) println(5::foo) bar("hello") bar(42) + return "OK" +// CHECK-LABEL: epilogue: } // CHECK-LABEL: define internal void @"kfun:$foo$FUNCTION_REFERENCE$0.#internal" diff --git a/compiler/testData/codegen/box/fileCheck/kt49847_sam_Any.kt b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Any.kt new file mode 100644 index 00000000000..47cc5068384 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Any.kt @@ -0,0 +1,23 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +fun interface Foo { + fun bar(x: Int): Any +} + +fun baz(x: Any): Int = x.hashCode() + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// Boxing needs to be used now due to non-devirtualized call +// CHECK-OPT: Int-box + +// CHECK-NOT: Int-box +// CHECK-NOT: Int-unbox +// CHECK-LABEL: epilogue: + +fun box(): String { + val foo: Foo = Foo(::baz) + return if (foo.bar(42) == 42) + "OK" + else "FAIL" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt49847_sam_Any_generic.kt b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Any_generic.kt new file mode 100644 index 00000000000..ac7d1661a36 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Any_generic.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +fun interface Foo { + fun bar(x: T): Any +} + +fun baz(x: Any): Int = x.hashCode() + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-NOT: Int-box +// CHECK-NOT: Int-unbox +// CHECK-LABEL: epilogue: +fun box(): String { + val foo: Foo = Foo(::baz) + return if (foo.bar(42) == 42) + "OK" + else "FAIL" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt49847_sam_Int.kt b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Int.kt new file mode 100644 index 00000000000..be0f7fc4f74 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Int.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +fun interface Foo { + fun bar(x: Int): Int +} + +fun baz(x: Int): Int = x.hashCode() + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-OPT-NOT: Int-box +// CHECK-DEBUG: Int-box +// CHECK-NOT: Int-unbox +// CHECK-LABEL: epilogue: +fun box(): String { + val foo: Foo = Foo(::baz) + val result = foo.bar(42) + return if( result == 42 ) + "OK" + else "FAIL: $result" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt49847_sam_Int_generic.kt b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Int_generic.kt new file mode 100644 index 00000000000..65d2465c656 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt49847_sam_Int_generic.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +fun interface Foo { + fun bar(x: T): Int +} + +fun baz(x: Any): Int = x.hashCode() + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-OPT-NOT: Int-box +// CHECK-DEBUG: Int-box +// CHECK-NOT: Int-unbox +// CHECK-LABEL: epilogue: +fun box(): String { + val foo: Foo = Foo(::baz) + val result = foo.bar(42) + return if( result == 42 ) + "OK" + else "FAIL: $result" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt49847_simple_function_reference.kt b/compiler/testData/codegen/box/fileCheck/kt49847_simple_function_reference.kt new file mode 100644 index 00000000000..bfd7bfc987b --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt49847_simple_function_reference.kt @@ -0,0 +1,22 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +fun plus1(x: Int) = x + 1 + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-OPT-NOT: Int-box +// CHECK-OPT-NOT: Int-unbox +// CHECK-DEBUG: Int-box +// CHECK-DEBUG: Int-unbox +// CHECK-LABEL: epilogue: +fun box(): String { + + val ref = ::plus1 + var y = 0 + repeat(100000) { + y += ref(it) // Should be devirtualized and invoked without boxing/unboxing (`Int-box`/`Int-unbox`) + } + if (y != 705082704) + return "FAIL $y != 705082704" + return "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_inline_unbox.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_inline_unbox.kt new file mode 100644 index 00000000000..ce4e658a8cd --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_inline_unbox.kt @@ -0,0 +1,73 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +import kotlin.native.concurrent.* +import kotlinx.cinterop.* + +val arr: Array = arrayOf("1") + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +@kotlinx.cinterop.ExperimentalForeignApi +fun box(): String { + println(arr.size.toByte() == arr[0].toByte()) + println(arr.size.toUByte() == arr[0].toUByte()) + println(arr.size.toShort() == arr[0].toShort()) + println(arr.size.toUShort() == arr[0].toUShort()) + println(arr.size.toInt() == arr[0].toInt()) + println(arr.size.toUInt() == arr[0].toUInt()) + println(arr.size.toLong() == arr[0].toLong()) + println(arr.size.toULong() == arr[0].toULong()) + println(arr.size.toFloat() == arr[0].toFloat()) + println(arr.size.toDouble() == arr[0].toDouble()) + println(Char(arr.size) == arr[0][0]) + println((arr.size == 1) == (arr[0] == "1")) // Boolean + + memScoped { + val var1: IntVar = alloc() + val var2: IntVar = alloc() + println(var1.ptr.rawValue == var2.ptr.rawValue) + } + + println(Result.success(arr.size) == Result.success(arr[0].toInt())) + println(vectorOf(arr.size, arr.size, arr.size, arr.size) == vectorOf(arr[0].toInt(), arr[0].toInt(), arr[0].toInt(), arr[0].toInt())) + + val w1 = Worker.start() + val w2 = Worker.start() + println(w1 == w2) + + val f1 = w1.requestTermination() + val f2 = w2.requestTermination() + println(f1 == f2) + + f1.result + f2.result + + return "OK" +} +// CHECK-OPT-NOT: {{call|invoke}} i64 @"kfun:kotlin# +// CHECK-OPT-NOT: {{call|invoke}} i64 @"kfun:kotlin# + +// CHECK-OPT-NOT: {{call|invoke}} i32 @"kfun:kotlin# +// CHECK-OPT-NOT: {{call|invoke}} i32 @"kfun:kotlin# + +// CHECK-OPT-NOT: {{call|invoke}} {{signext i16|i16}} @"kfun:kotlin# +// CHECK-OPT-NOT: {{call|invoke}} {{zeroext i16|i16}} @"kfun:kotlin# + +// CHECK-OPT-NOT: {{call|invoke}} {{signext i8|i8}} @"kfun:kotlin# +// CHECK-OPT-NOT: {{call|invoke}} {{zeroext i8|i8}} @"kfun:kotlin# + +// CHECK-OPT-NOT: {{call|invoke}} {{zeroext i16|i16}} @"kfun:kotlin# +// CHECK-OPT-NOT: {{call|invoke}} {{zeroext i1|i1}} @"kfun:kotlin# + +// CHECK-OPT-NOT: {{call|invoke}} double @"kfun:kotlin# +// CHECK-OPT-NOT: {{call|invoke}} float @"kfun:kotlin# + +// CHECK-OPT-NOT: {{call|invoke}} i8* @"kfun:kotlin.native.internal# +// CHECK-OPT-NOT: {{call|invoke}} i32 @"kfun:kotlin.native.concurrent# +// CHECK-OPT-NOT: {{call|invoke}} i32 @"kfun:kotlin.native.concurrent# +// CHECK-OPT-NOT: {{call|invoke}} <4 x float> @"kfun:kotlin.native# +// CHECK-OPT-NOT: {{call|invoke}} %struct.ObjHeader* @"kfun:kotlin# + +// CHECK-LABEL: epilogue: +// On APPLE targets, generated functions ToNSNumber may contain non-converted invocations of unbox functions. +// CHECK-APPLE: {{IntToNSNumber|LongToNSNumber|ByteToNSNumber|ShortToNSNumber|FloatToNSNumber|DoubleToNSNumber}} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_CPointer.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_CPointer.kt new file mode 100644 index 00000000000..26cc50c2ba8 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_CPointer.kt @@ -0,0 +1,22 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +import kotlinx.cinterop.* + +// CHECK-AAPCS-OPT-LABEL: define i1 @"kfun:kotlinx.cinterop.CPointer#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-OPT-LABEL: define zeroext i1 @"kfun:kotlinx.cinterop.CPointer#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-OPT-LABEL: define zeroext i1 @"kfun:kotlinx.cinterop.CPointer#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-OPT: call i8* @"kfun:kotlinx.cinterop#(kotlin.Any?){}kotlinx.cinterop.CPointer<-1:0>?" + +// CHECK-DEBUG-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-DEBUG: [[var1:%[0-9]+]] = invoke i8* @"kfun:kotlinx.cinterop# +// CHECK-DEBUG: [[var2:%[0-9]+]] = invoke i8* @"kfun:kotlinx.cinterop# +// CHECK-DEBUG: = icmp eq i8* [[var1]], [[var2]] +// CHECK-DEBUG-LABEL: epilogue: + +@kotlinx.cinterop.ExperimentalForeignApi +fun box(): String = memScoped { + val var1: IntVar = alloc() + val var2: IntVar = alloc() + return if (var1.ptr == var2.ptr) "FAIL" else "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NativePointed.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NativePointed.kt new file mode 100644 index 00000000000..72ecf2b59cf --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NativePointed.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +import kotlinx.cinterop.* + +// CHECK-OPT-LABEL: define i8* @"kfun:kotlinx.cinterop#interpretOpaquePointed(kotlin.native.internal.NativePtr){}kotlinx.cinterop.NativePointed"(i8* %0) +// CHECK-OPT: call i8* @"kfun:kotlinx.cinterop#(kotlin.Any?){}kotlinx.cinterop.NativePointed?" + +// CHECK-DEBUG-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-AAPCS-DEBUG: call i1 @IsSubtype(%struct.TypeInfo* %{{[0-9]+}}, %struct.TypeInfo* getelementptr inbounds ({{.*}}@"kclass:kotlinx.cinterop.NativePointed", i32 0, i32 0)) +// CHECK-DEFAULTABI-DEBUG: call zeroext i1 @IsSubtype(%struct.TypeInfo* %{{[0-9]+}}, %struct.TypeInfo* @"kclass:kotlinx.cinterop.NativePointed") +// CHECK-WINDOWSX64-DEBUG: call zeroext i1 @IsSubtype(%struct.TypeInfo* %{{[0-9]+}}, %struct.TypeInfo* getelementptr inbounds ({{.*}}@"kclass:kotlinx.cinterop.NativePointed", i32 0, i32 0)) +// CHECK-DEBUG-LABEL: epilogue: + +@kotlinx.cinterop.ExperimentalForeignApi +fun box(): String = memScoped { + val var1: NativePointed = alloc(4, 4) + return if (interpretOpaquePointed(var1.rawPtr) is NativePointed) "OK" else "FAIL" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NonNullNativePtr.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NonNullNativePtr.kt new file mode 100644 index 00000000000..0acdc20151d --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NonNullNativePtr.kt @@ -0,0 +1,24 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +import kotlinx.cinterop.* + +// CHECK-AAPCS-OPT-LABEL: define i1 @"kfun:kotlin.native.internal.NonNullNativePtr#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-OPT-LABEL: define zeroext i1 @"kfun:kotlin.native.internal.NonNullNativePtr#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-OPT-LABEL: define zeroext i1 @"kfun:kotlin.native.internal.NonNullNativePtr#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-OPT: call i8* @"kfun:kotlin.native.internal#(kotlin.Any?){}kotlin.native.internal.NonNullNativePtr?" + +// CHECK-DEBUG-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +// CHECK-AAPCS-DEBUG: invoke i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-DEFAULTABI-DEBUG: invoke zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-WINDOWSX64-DEBUG: invoke zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-DEBUG-LABEL: epilogue: + +@kotlinx.cinterop.ExperimentalForeignApi +fun box(): String = memScoped { + val var1: IntVar = alloc() + val var2: IntVar = alloc() + // The first one is K1, the second one is K2. + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + return if (var1.ptr.value as Any == var2.ptr.value as Any) "FAIL" else "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_StableRef.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_StableRef.kt new file mode 100644 index 00000000000..e13abba8ca6 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_StableRef.kt @@ -0,0 +1,30 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +import kotlinx.cinterop.* + +// CHECK-AAPCS-OPT-LABEL: define i1 @"kfun:kotlinx.cinterop.StableRef#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-OPT-LABEL: define zeroext i1 @"kfun:kotlinx.cinterop.StableRef#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-OPT-LABEL: define zeroext i1 @"kfun:kotlinx.cinterop.StableRef#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) + +// CHECK-OPT: call i8* @"kfun:kotlinx.cinterop#(kotlin.Any?){}kotlinx.cinterop.StableRef<-1:0>?" + +// CHECK-OPT-LABEL: epilogue: + + +// CHECK-DEBUG-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" + +// CHECK-DEBUG: [[result:%[0-9]+]] = icmp eq i8* +// CHECK-DEBUG: store i1 [[result]], i1* %isEqual + +// CHECK-DEBUG-LABEL: epilogue: + +@kotlinx.cinterop.ExperimentalForeignApi +fun box(): String { + val ref1 = StableRef.create(Any()) + val ref2 = StableRef.create(Any()) + val isEqual = ref1 == ref2 + ref2.dispose() + ref1.dispose() + return if (!isEqual) "OK" else "FAIL" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UByteArray.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UByteArray.kt new file mode 100644 index 00000000000..6462cc5327d --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UByteArray.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +// CHECK-AAPCS-OPT-LABEL: define i1 @"kfun:kotlin.UByteArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-OPT-LABEL: define zeroext i1 @"kfun:kotlin.UByteArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-OPT-LABEL: define zeroext i1 @"kfun:kotlin.UByteArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.UByteArray?" +// CHECK-AAPCS-DEBUG: call i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-DEFAULTABI-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-WINDOWSX64-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" + +// CHECK-LABEL: epilogue: + +fun box(): String { + val arr1 = UByteArray(10) { it.toUByte() } + val arr2 = UByteArray(10) { (it / 2).toUByte() } + return if (arr1 == arr2) "FAIL" else "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UIntArray.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UIntArray.kt new file mode 100644 index 00000000000..4ee27064953 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UIntArray.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +// CHECK-AAPCS-OPT-LABEL: define i1 @"kfun:kotlin.UIntArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-OPT-LABEL: define zeroext i1 @"kfun:kotlin.UIntArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-OPT-LABEL: define zeroext i1 @"kfun:kotlin.UIntArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.UIntArray?" +// CHECK-AAPCS-DEBUG: call i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-DEFAULTABI-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-WINDOWSX64-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" + +// CHECK-LABEL: epilogue: + +fun box(): String { + val arr1 = UIntArray(10) { it.toUInt() } + val arr2 = UIntArray(10) { (it / 2).toUInt() } + return if (arr1 == arr2) "FAIL" else "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_ULongArray.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_ULongArray.kt new file mode 100644 index 00000000000..9e878798f35 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_ULongArray.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +// CHECK-AAPCS-OPT-LABEL: define i1 @"kfun:kotlin.ULongArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-OPT-LABEL: define zeroext i1 @"kfun:kotlin.ULongArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-OPT-LABEL: define zeroext i1 @"kfun:kotlin.ULongArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.ULongArray?" +// CHECK-AAPCS-DEBUG: call i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-DEFAULTABI-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-WINDOWSX64-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" + +// CHECK-LABEL: epilogue: + +fun box(): String { + val arr1 = ULongArray(10) { it.toULong() } + val arr2 = ULongArray(10) { (it / 2).toULong() } + return if (arr1 == arr2) "FAIL" else "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UShortArray.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UShortArray.kt new file mode 100644 index 00000000000..888ab68739a --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UShortArray.kt @@ -0,0 +1,21 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +// CHECK-AAPCS-OPT-LABEL: define i1 @"kfun:kotlin.UShortArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-OPT-LABEL: define zeroext i1 @"kfun:kotlin.UShortArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-OPT-LABEL: define zeroext i1 @"kfun:kotlin.UShortArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.UShortArray?" +// CHECK-AAPCS-DEBUG: call i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-DEFAULTABI-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" +// CHECK-WINDOWSX64-DEBUG: call zeroext i1 @"kfun:kotlin.Any#equals(kotlin.Any?){}kotlin.Boolean-trampoline" + +// CHECK-LABEL: epilogue: + +fun box(): String { + val arr1 = UShortArray(10) { it.toUShort() } + val arr2 = UShortArray(10) { (it / 2).toUShort() } + return if (arr1 == arr2) "FAIL" else "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_value_unbox.kt b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_value_unbox.kt new file mode 100644 index 00000000000..c82f8f3b23f --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_value_unbox.kt @@ -0,0 +1,12 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +// CHECK-AAPCS-LABEL: define i1 @"kfun:C#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:C#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:C#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) +// CHECK: call %struct.ObjHeader* @"kfun:#(kotlin.Any?){}C?" +value class C(val x: Any) +// Note: is also called from bridges for equals, hashCode and toString. + +fun box() = + if (C(42) == C(13)) "FAIL" else "OK" diff --git a/kotlin-native/backend.native/tests/filecheck/kt58654.kt b/compiler/testData/codegen/box/fileCheck/kt58654.kt similarity index 65% rename from kotlin-native/backend.native/tests/filecheck/kt58654.kt rename to compiler/testData/codegen/box/fileCheck/kt58654.kt index d30edda6490..ee332b79837 100644 --- a/kotlin-native/backend.native/tests/filecheck/kt58654.kt +++ b/compiler/testData/codegen/box/fileCheck/kt58654.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs // CHECK-LABEL: define i64 @"kfun:#foo(){}kotlin.Long"() fun foo(): Long { @@ -28,7 +26,11 @@ fun callBar(f: Boolean): ULong { } // CHECK: ret i64 -fun main() { - println(foo()) - println(callBar(true)) +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + val resultFoo = foo() + val resultBar = callBar(false) + return if (resultFoo == 0L && resultBar == 1UL) + "OK" + else "FAIL: resultFoo=$resultFoo resultBar=$resultBar" } diff --git a/kotlin-native/backend.native/tests/filecheck/no_frame_on_constant_object_access.kt b/compiler/testData/codegen/box/fileCheck/no_frame_on_constant_object_access.kt similarity index 67% rename from kotlin-native/backend.native/tests/filecheck/no_frame_on_constant_object_access.kt rename to compiler/testData/codegen/box/fileCheck/no_frame_on_constant_object_access.kt index b8bc03c032b..752f1692474 100644 --- a/kotlin-native/backend.native/tests/filecheck/no_frame_on_constant_object_access.kt +++ b/compiler/testData/codegen/box/fileCheck/no_frame_on_constant_object_access.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs object A { const val x = 5 @@ -31,7 +29,11 @@ fun g() { // CHECK: {{^}}epilogue: -fun main() { - f() +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + val f = f() + if (f != 12) + return "FAIL: $f != 12" g() + return "OK" } \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/replace_invoke_with_call.kt b/compiler/testData/codegen/box/fileCheck/replace_invoke_with_call.kt similarity index 50% rename from kotlin-native/backend.native/tests/filecheck/replace_invoke_with_call.kt rename to compiler/testData/codegen/box/fileCheck/replace_invoke_with_call.kt index 4c1ebb24c4a..c548d22249a 100644 --- a/kotlin-native/backend.native/tests/filecheck/replace_invoke_with_call.kt +++ b/compiler/testData/codegen/box/fileCheck/replace_invoke_with_call.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs fun flameThrower() { throw Throwable("🔥") @@ -11,7 +9,7 @@ fun flameThrower() { fun f1() { // CHECK: call void @"kfun:#flameThrower(){}"() flameThrower() -// CHECK-LABEL: epilogue +// CHECK-LABEL: epilogue: } // CHECK-LABEL: "kfun:#f2(){}" @@ -20,12 +18,15 @@ fun f2() { // CHECK: invoke void @"kfun:#flameThrower(){}"() flameThrower() } catch (t: Throwable) {} -// CHECK-LABEL: epilogue +// CHECK-LABEL: epilogue: } -// CHECK-LABEL: "kfun:#main(){}" -fun main() { - f1() +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + try { + f1() + } catch (t: Throwable) {} f2() -// CHECK-LABEL: epilogue +// CHECK-LABEL: epilogue: + return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/fileCheck/signext_zeroext0.kt b/compiler/testData/codegen/box/fileCheck/signext_zeroext0.kt new file mode 100644 index 00000000000..f393def42b1 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/signext_zeroext0.kt @@ -0,0 +1,157 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +// CHECK-DEFAULTABI-LABEL: define zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext %0) +// CHECK-AAPCS-LABEL: define i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 %0) +// CHECK-WINDOWSX64-LABEL: define zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext %0) +fun id(arg: Boolean): Boolean { + return arg +} + +// CHECK-DEFAULTABI-LABEL: define signext i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 signext %0) +// CHECK-AAPCS-LABEL: define i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 %0) +// CHECK-WINDOWSX64-LABEL: define i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 %0) +fun id(arg: Byte): Byte { + return arg +} + +// CHECK-DEFAULTABI-LABEL: define zeroext i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 zeroext %0) +// CHECK-AAPCS-LABEL: define i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 %0) +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 %0) +fun id(arg: Char): Char { + return arg +} + +// CHECK-DEFAULTABI-LABEL: define signext i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 signext %0) +// CHECK-AAPCS-LABEL: define i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 %0) +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 %0) +fun id(arg: Short): Short { + return arg +} + +// CHECK-LABEL: define i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 %0) +fun id(arg: Int): Int { + return arg +} + +// CHECK-LABEL: define i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 %0) +fun id(arg: Long): Long { + return arg +} + +// CHECK-LABEL: define float @"kfun:#id(kotlin.Float){}kotlin.Float"(float %0) +fun id(arg: Float): Float { + return arg +} + +// CHECK-LABEL: define double @"kfun:#id(kotlin.Double){}kotlin.Double"(double %0) +fun id(arg: Double): Double { + return arg +} + +// CHECK-DEFAULTABI-LABEL: define zeroext i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 zeroext %0) +// CHECK-AAPCS-LABEL: define i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 %0) +// CHECK-WINDOWSX64-LABEL: define i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 %0) +fun id(arg: UByte): UByte { + return arg +} + +// CHECK-DEFAULTABI-LABEL: define zeroext i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 zeroext %0) +// CHECK-AAPCS-LABEL: define i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 %0) +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 %0) +fun id(arg: UShort): UShort { + return arg +} + +// CHECK-LABEL: define i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 %0) +fun id(arg: UInt): UInt { + return arg +} + +// CHECK-LABEL: define i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 %0) +fun id(arg: ULong): ULong { + return arg +} + +fun checkPrimitives() { + // CHECK-DEFAULTABI: call zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext {{.*}}) + // CHECK-AAPCS: call i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 {{.*}}) + // CHECK-WINDOWSX64: call zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext {{.*}}) + id(true) + // CHECK-DEFAULTABI: call signext i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 signext {{.*}}) + // CHECK-AAPCS: call i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 {{.*}}) + // CHECK-WINDOWSX64: call i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 {{.*}}) + id(0.toByte()) + // CHECK-DEFAULTABI: call zeroext i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 zeroext {{.*}}) + // CHECK-AAPCS: call i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 {{.*}}) + // CHECK-WINDOWSX64: call i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 {{.*}}) + id('a') + // CHECK-DEFAULTABI: call signext i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 signext {{.*}}) + // CHECK-AAPCS: call i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 {{.*}}) + // CHECK-WINDOWSX64: call i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 {{.*}}) + id(0.toShort()) + // CHECK: call i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 {{.*}}) + id(0) + // CHECK: call i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 {{.*}}) + id(0L) + // CHECK: call float @"kfun:#id(kotlin.Float){}kotlin.Float"(float {{.*}}) + id(0.5f) + // CHECK: call double @"kfun:#id(kotlin.Double){}kotlin.Double"(double {{.*}}) + id(0.5) + // CHECK-DEFAULTABI: call zeroext i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 zeroext {{.*}}) + // CHECK-AAPCS: call i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 {{.*}}) + // CHECK-WINDOWSX64: call i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 {{.*}}) + id(0.toUByte()) + // CHECK-DEFAULTABI: call zeroext i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 zeroext {{.*}}) + // CHECK-AAPCS: call i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 {{.*}}) + // CHECK-WINDOWSX64: call i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 {{.*}}) + id(0.toUShort()) + // CHECK: call i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 {{.*}}) + id(15u) + // CHECK: call i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 {{.*}}) + id(15uL) +} + +value class CharWrapper(val ch: Char) + +// CHECK-DEFAULTABI-LABEL: define zeroext i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 zeroext %0) +// CHECK-AAPCS-LABEL: define i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 %0) +// CHECK-WINDOWSX64-LABEL: define i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 %0) +fun id(arg: CharWrapper): CharWrapper { + return arg +} + +// Check that value classes doesn't affect parameter attributes + +fun checkInlineClasses() { + // CHECK-DEFAULTABI: call zeroext i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 zeroext {{.*}}) + // CHECK-AAPCS: call i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 {{.*}}) + // CHECK-WINDOWSX64: call i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 {{.*}}) + id(CharWrapper('c')) +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) +fun nullableId(arg: Byte?): Byte? { + return arg +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) +fun nullableId(arg: CharWrapper?): CharWrapper? { + return arg +} + +// Check that we don't pass primitive-specific attributes to their boxes +fun checkBoxes() { + // CHECK: call %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) + nullableId(1.toByte()) + // CHECK: call %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) + nullableId(CharWrapper('a')) +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + checkPrimitives() + checkInlineClasses() + checkBoxes() + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/fileCheck/single_tls_load.kt b/compiler/testData/codegen/box/fileCheck/single_tls_load.kt new file mode 100644 index 00000000000..4ea95363c54 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/single_tls_load.kt @@ -0,0 +1,29 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: OptimizeTLSDataLoads + +class Wrapper(x: Int) + +// CHECK-LABEL: define internal fastcc %struct.ObjHeader* @"kfun:#f(kotlin.Int;kotlin.String){}kotlin.String" +fun f(x: Int, s: String): String { + // CHECK: _ZN6kotlin2mm14ThreadRegistry22currentThreadDataNode_E + // CHECK-NOT: _ZN6kotlin2mm14ThreadRegistry22currentThreadDataNode_E + if (x < 0) throw IllegalStateException() + if (x > 0) return f(x - 1, s) + val b = Wrapper(2) + val a = listOf(x, x, Wrapper(1), 2, x) + return buildString { + for (i in a) { appendLine("$s i") } + } +// CHECK-LABEL: epilogue: +} + +fun box(): String { + val result = f(10, "123456") + return if (result == "123456 i\n" + + "123456 i\n" + + "123456 i\n" + + "123456 i\n" + + "123456 i\n") + "OK" + else "FAIL: $result" +} diff --git a/compiler/testData/codegen/box/fileCheck/smoke0.kt b/compiler/testData/codegen/box/fileCheck/smoke0.kt new file mode 100644 index 00000000000..ddc4d793e29 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/smoke0.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +// CHECK-LABEL: "kfun:#id(kotlin.Any?){}kotlin.Any?" +fun id(a: Any?): Any? { + return a +// CHECK-LABEL: epilogue: +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + // CHECK: call %struct.ObjHeader* @"kfun:#id(kotlin.Any?){}kotlin.Any?" + val x = id("Hello") + // CHECK: call void @"kfun:kotlin.io#println(kotlin.Any?){}"(%struct.ObjHeader* {{.*}}) + println(x) +// CHECK-LABEL: epilogue: + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_generated.kt b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_generated.kt new file mode 100644 index 00000000000..3aedc9c7cff --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_generated.kt @@ -0,0 +1,114 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +package codegen.stringConcatenationTypeNarrowing.kt53119_append_generated +import kotlin.test.* + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyMaybeAny +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK: ret %struct.ObjHeader* + +fun maybeAnyMaybeAny(maybeAny1: Any?, maybeAny2: Any?): String { + return "$maybeAny1,$maybeAny2" +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyMaybeString +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append +// CHECK: ret %struct.ObjHeader* + +fun maybeAnyMaybeString(maybeAny1: Any?, maybeString2: String?): String { + return "$maybeAny1,$maybeString2" +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyString +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append +// CHECK: ret %struct.ObjHeader* + +fun maybeAnyString(maybeAny1: Any?, string: String): String { + return "$maybeAny1,$string" +} + +data class Foo(val bar: Int) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyFoo +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append +// CHECK: ret %struct.ObjHeader* + +fun maybeAnyFoo(maybeAny: Any?, foo: Foo): String { + return "$maybeAny,$foo" +} +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyMaybeFoo +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + + +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append +// CHECK: ret %struct.ObjHeader* + +fun maybeAnyMaybeFoo(maybeAny: Any?, foo: Foo?): String { + return "$maybeAny,$foo" +} + +fun box(): String { + val foo = Foo(42) + val res1 = maybeAnyMaybeAny(foo, foo) + if (res1 != "Foo(bar=42),Foo(bar=42)") return "FAIL1: $res1" + val res2 = maybeAnyMaybeAny(null, null) + if (res2 != "null,null") return "FAIL2: $res2" + val res3 = maybeAnyMaybeString(foo, "bar") + if (res3 != "Foo(bar=42),bar") return "FAIL3: $res3" + val res4 = maybeAnyMaybeString(null, null) + if (res4 != "null,null") return "FAIL4: $res4" + val res5 = maybeAnyString(foo, "bar") + if (res5 != "Foo(bar=42),bar") return "FAIL5: $res5" + val res6 = maybeAnyString(null, "bar") + if (res6 != "null,bar") return "FAIL6: $res6" + val res7 = maybeAnyFoo(foo, foo) + if (res7 != "Foo(bar=42),Foo(bar=42)") return "FAIL7: $res7" + val res8 = maybeAnyFoo(null, foo) + if (res8 != "null,Foo(bar=42)") return "FAIL8: $res8" + val res9 = maybeAnyMaybeFoo(foo, foo) + if (res9 != "Foo(bar=42),Foo(bar=42)") return "FAIL9: $res9" + val res10 = maybeAnyMaybeFoo(foo, null) + if (res10 != "Foo(bar=42),null") return "FAIL10: $res10" + return "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_manual.kt b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_manual.kt new file mode 100644 index 00000000000..01226c149e4 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_manual.kt @@ -0,0 +1,98 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +package codegen.stringConcatenationTypeNarrowing.kt53119_append_manual +import kotlin.test.* + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendMaybeAny(kotlin.Any?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK: ret %struct.ObjHeader* + +fun appendMaybeAny(maybeAny: Any?): String { + val sb = kotlin.text.StringBuilder() + sb.append(maybeAny) + return sb.toString() +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendAny(kotlin.Any) +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) + +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append +// CHECK: ret %struct.ObjHeader* + +fun appendAny(any: Any): String { + val sb = kotlin.text.StringBuilder() + sb.append(any) + return sb.toString() +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendMaybeString(kotlin.String?) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String + +// CHECK: ret %struct.ObjHeader* + +fun appendMaybeString(maybeStr: String?): String { + val sb = kotlin.text.StringBuilder() + sb.append(maybeStr) + return sb.toString() +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendString(kotlin.String) +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append + +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String + +// CHECK: ret %struct.ObjHeader* + +fun appendString(str: String): String { + val sb = kotlin.text.StringBuilder() + sb.append(str) + return sb.toString() +} + +data class Foo(val bar: Int) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendFoo(codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo) +// CHECK-OPT: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) + +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append +// CHECK: ret %struct.ObjHeader* + +fun appendFoo(foo: Foo): String { + val sb = kotlin.text.StringBuilder() + sb.append(foo) + return sb.toString() +} + +fun box(): String { + val foo = Foo(42) + val res1 = appendMaybeAny(foo) + if (res1 != "Foo(bar=42)") return "FAIL1: $res1" + val res2 = appendMaybeAny(null) + if (res2 != "null") return "FAIL2: $res2" + val res3 = appendAny(foo) + if (res3 != "Foo(bar=42)") return "FAIL3: $res3" + val res4 = appendMaybeString("foo") + if (res4 != "foo") return "FAIL4: $res4" + val res5 = appendMaybeString(null) + if (res5 != "null") return "FAIL5: $res5" + val res6 = appendString("foo") + if (res6 != "foo") return "FAIL6: $res6" + val res7 = appendFoo(foo) + if (res7 != "Foo(bar=42)") return "FAIL7: $res7" + return "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt new file mode 100644 index 00000000000..db3f8f39270 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt @@ -0,0 +1,132 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +package codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension +import kotlin.test.* + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#manualPlusExtensionAny +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl + +// CHECK: ret %struct.ObjHeader* + +fun manualPlusExtensionAny(maybeStr: String?, maybeAny: kotlin.Any?): kotlin.String = + maybeStr + maybeAny + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#manualPlusExtensionString +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl + +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK: ret %struct.ObjHeader* + +fun manualPlusExtensionString(maybeStr: String?, str: String): kotlin.String = + maybeStr + str + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionAny +// CHECK-OPT-NOT: kfun:kotlin#plus__at__kotlin.String?(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: kfun:kotlin#plus__at__kotlin.String?(kotlin.Any?) +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" + +// CHECK: ret %struct.ObjHeader* + +fun generatedPlusExtensionAny(maybeStr: String?, maybeAny: Any?): String { + return "$maybeStr$maybeAny" +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionString +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl + +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK: ret %struct.ObjHeader* + +fun generatedPlusExtensionString(maybeStr: String?, str: String): String { + return "$maybeStr$str" +} + +data class Foo(val bar: Int) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionFoo +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl + +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK: ret %struct.ObjHeader* + +fun generatedPlusExtensionFoo(maybeStr: String?, foo: Foo): String { + return "$maybeStr$foo" +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionMaybeFoo +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" + +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK: ret %struct.ObjHeader* + +fun generatedPlusExtensionMaybeFoo(maybeStr: String?, foo: Foo?): String { + return "$maybeStr$foo" +} + +fun box(): String { + val foo = Foo(42) + val res1 = manualPlusExtensionAny("foo", foo) + if (res1 != "fooFoo(bar=42)") return "FAIL1: $res1" + val res2 = manualPlusExtensionAny(null, null) + if (res2 != "nullnull") return "FAIL2: $res2" + val res3 = manualPlusExtensionString("foo", "bar") + if (res3 != "foobar") return "FAIL3: $res3" + val res4 = manualPlusExtensionString(null, "bar") + if (res4 != "nullbar") return "FAIL4: $res4" + val res5 = generatedPlusExtensionAny("foo", foo) + if (res5 != "fooFoo(bar=42)") return "FAIL5: $res5" + val res6 = generatedPlusExtensionAny(null, null) + if (res6 != "nullnull") return "FAIL6: $res6" + val res7 = generatedPlusExtensionString("foo", "bar") + if (res7 != "foobar") return "FAIL7: $res7" + val res8 = generatedPlusExtensionString(null, "bar") + if (res8 != "nullbar") return "FAIL8: $res8" + val res9 = generatedPlusExtensionFoo(null, Foo(42)) + if (res9 != "nullFoo(bar=42)") return "FAIL9: $res9" + val res10 = generatedPlusExtensionMaybeFoo("foo", Foo(42)) + if (res10 != "fooFoo(bar=42)") return "FAIL10: $res10" + val res11 = generatedPlusExtensionMaybeFoo("foo", null) + if (res11 != "foonull") return "FAIL11: $res11" + return "OK" +} diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt similarity index 79% rename from kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt rename to compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt index cdda5787b13..70c0213f490 100644 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt +++ b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs package codegen.stringConcatenationTypeNarrowing.kt53119_plus_generated_noescape import kotlin.test.* @@ -24,7 +22,8 @@ fun getNextInt(): Int { return Random.nextInt(IntRange(42153, 42153)) } -@Test -fun runTest() { - println(getNextInt()) +fun box(): String { + val nextInt = getNextInt() + if (nextInt != 42153) return "FAIL: $nextInt != 42153" + return "OK" } diff --git a/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_member.kt b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_member.kt new file mode 100644 index 00000000000..2c3dcb6e236 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_member.kt @@ -0,0 +1,111 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +package codegen.stringConcatenationTypeNarrowing.kt53119_plus_member +import kotlin.test.* + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberAny +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK: ret %struct.ObjHeader* + +fun manualPlusMemberAny(str: String, maybeAny: kotlin.Any?): kotlin.String = + str + maybeAny + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberString +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" + +// CHECK: ret %struct.ObjHeader* + +fun manualPlusMemberString(str1: String, str2: String): kotlin.String = + str1 + str2 + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#generatedPlusMemberAny +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK: ret %struct.ObjHeader* + +fun generatedPlusMemberAny(str: String, maybeAny: Any?): String { + return "$str$maybeAny" +} + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#generatedPlusMemberString +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl + +// CHECK-OPT-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK: ret %struct.ObjHeader* + +fun generatedPlusMemberString(str1: String, str2: String): String { + return "$str1$str2" +} + +data class Foo(val bar: Int) + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberFoo +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT Foo#toString(){}kotlin.String + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" + +// CHECK: ret %struct.ObjHeader* +fun manualPlusMemberFoo(str1: String, foo: Foo): kotlin.String = + str1 + foo + +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberMaybeFoo +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) +// CHECK-OPT: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String +// CHECK-OPT-NOT: kfun:kotlin.String#plus(kotlin.Any?) + +// CHECK-OPT: call %struct.ObjHeader* @Kotlin_String_plusImpl +// CHECK-OPT-NOT: Foo#toString(){}kotlin.String" + +// CHECK: ret %struct.ObjHeader* +fun manualPlusMemberMaybeFoo(str1: String, foo: Foo?): kotlin.String = + str1 + foo + +fun box(): String { + val foo = Foo(42) + val res1 = manualPlusMemberAny("foo", foo) + if (res1 != "fooFoo(bar=42)") return "FAIL1: $res1" + val res2 = manualPlusMemberAny("foo", null) + if (res2 != "foonull") return "FAIL2: $res2" + val res3 = manualPlusMemberString("foo", "bar") + if (res3 != "foobar") return "FAIL3: $res3" + val res4 = generatedPlusMemberAny("foo", null) + if (res4 != "foonull") return "FAIL4: $res4" + val res5 = generatedPlusMemberAny("foo", foo) + if (res5 != "fooFoo(bar=42)") return "FAIL5: $res5" + val res6 = generatedPlusMemberString("foo", "bar") + if (res6 != "foobar") return "FAIL6: $res6" + val res7 = manualPlusMemberFoo("foo", Foo(42)) + if (res7 != "fooFoo(bar=42)") return "FAIL7: $res7" + val res8 = manualPlusMemberMaybeFoo("foo", Foo(42)) + if (res8 != "fooFoo(bar=42)") return "FAIL8: $res8" + val res9 = manualPlusMemberMaybeFoo("foo", null) + if (res9 != "foonull") return "FAIL9: $res9" + return "OK" +} diff --git a/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt new file mode 100644 index 00000000000..c40ed658003 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt @@ -0,0 +1,27 @@ +// WITH_STDLIB +import kotlin.collections.* + +val sideEffectsHolder = mutableListOf() +fun withSideEffect(param: Int): String? { + sideEffectsHolder.add(param) + return "Result $param" +} + +fun box(): String { + val result1 = "Result1 is: " + withSideEffect(1) + if (result1 != "Result1 is: Result 1") return "FAIL 1: $result1" + if (sideEffectsHolder != listOf(1)) return "FAIL 1 sideffects: $sideEffectsHolder" + sideEffectsHolder.clear() + val result2 = "Result2 is: " + withSideEffect(2) + "!" + if (result2 != "Result2 is: Result 2!") return "FAIL 2: $result2" + if (sideEffectsHolder != listOf(2)) return "FAIL 2 sideffects: $sideEffectsHolder" + sideEffectsHolder.clear() + val result3 = withSideEffect(31) + withSideEffect(32) + if (result3 != "Result 31Result 32") return "FAIL 3: $result3" + if (sideEffectsHolder != listOf(31,32)) return "FAIL 3 sideffects: $sideEffectsHolder" + sideEffectsHolder.clear() + val result4 = withSideEffect(41) + withSideEffect(42) + withSideEffect(43) + if (result4 != "Result 41Result 42Result 43") return "FAIL 4: $result4" + if (sideEffectsHolder != listOf(41,42,43)) return "FAIL 4 sideffects: $sideEffectsHolder" + return "OK" +} diff --git a/kotlin-native/backend.native/tests/filecheck/suspend_returnNothing.kt b/compiler/testData/codegen/box/fileCheck/suspend_returnNothing.kt similarity index 78% rename from kotlin-native/backend.native/tests/filecheck/suspend_returnNothing.kt rename to compiler/testData/codegen/box/fileCheck/suspend_returnNothing.kt index fc98f4c65ed..b385a94cd75 100644 --- a/kotlin-native/backend.native/tests/filecheck/suspend_returnNothing.kt +++ b/compiler/testData/codegen/box/fileCheck/suspend_returnNothing.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs import kotlin.test.* @@ -33,10 +31,11 @@ fun builder(c: suspend () -> Unit) { c.startCoroutine(EmptyContinuation) } -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { builder { bar() } - println("OK") + return "OK" } diff --git a/kotlin-native/backend.native/tests/filecheck/suspend_tailcalls_functions.kt b/compiler/testData/codegen/box/fileCheck/suspend_tailcalls_functions.kt similarity index 98% rename from kotlin-native/backend.native/tests/filecheck/suspend_tailcalls_functions.kt rename to compiler/testData/codegen/box/fileCheck/suspend_tailcalls_functions.kt index 0b29c52d41d..af8be3644a1 100644 --- a/kotlin-native/backend.native/tests/filecheck/suspend_tailcalls_functions.kt +++ b/compiler/testData/codegen/box/fileCheck/suspend_tailcalls_functions.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* @@ -290,7 +288,8 @@ fun builder(c: suspend () -> Unit) { c.startCoroutine(EmptyContinuation) } -fun main() { +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { builder { s1() s2() @@ -317,4 +316,5 @@ fun main() { s23(true) s24() } + return "OK" } \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/suspend_tailcalls_lambdas.kt b/compiler/testData/codegen/box/fileCheck/suspend_tailcalls_lambdas.kt similarity index 98% rename from kotlin-native/backend.native/tests/filecheck/suspend_tailcalls_lambdas.kt rename to compiler/testData/codegen/box/fileCheck/suspend_tailcalls_lambdas.kt index 512d89614f7..c671016f94e 100644 --- a/kotlin-native/backend.native/tests/filecheck/suspend_tailcalls_lambdas.kt +++ b/compiler/testData/codegen/box/fileCheck/suspend_tailcalls_lambdas.kt @@ -1,7 +1,5 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* @@ -43,6 +41,34 @@ fun builderInt(c: suspend () -> Int) { c.startCoroutine(EmptyContinuation) } +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String { + s1() + s2() + s3() + s4() + s5() + s6() + s7() + s8() + s9() + s10() + s11() + s12() + s13() + s14() + s15() + s16() + s17() + s18(true) + s19(true) + s20(true) + s21() + s22() + s23(true) + s24() + return "OK" +} fun s1() { // CHECK-LABEL: define internal %struct.ObjHeader* @"kfun:s1$lambda${{[0-9]*}} @@ -354,30 +380,3 @@ fun s24() { } // CHECK-LABEL: epilogue: } - -fun main() { - s1() - s2() - s3() - s4() - s5() - s6() - s7() - s8() - s9() - s10() - s11() - s12() - s13() - s14() - s15() - s16() - s17() - s18(true) - s19(true) - s20(true) - s21() - s22() - s23(true) - s24() -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/fileCheck/when.kt b/compiler/testData/codegen/box/fileCheck/when.kt new file mode 100644 index 00000000000..58e1ee135c5 --- /dev/null +++ b/compiler/testData/codegen/box/fileCheck/when.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: NATIVE +// FILECHECK_STAGE: CStubs + +var i = 1 +// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#box(){}kotlin.String" +fun box(): String = when(i) { + 0 -> "FAIL: 0" + 1 -> "OK" + 2 -> "FAIL: 2" + else -> "FAIL: else" +} +// CHECK: when_case +// CHECK: when_next +// CHECK: when_case1 +// CHECK: when_next2 +// CHECK: when_case3 +// CHECK: when_next4 +// CHECK: when_exit +// CHECK: ret void 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 63d72c27799..b8c135844a0 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 @@ -17888,6 +17888,42 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") 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 8dcbfea7a56..66c5d677b50 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 @@ -18704,6 +18704,42 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index a4cea90c214..fd9492f134f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -18704,6 +18704,42 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3a9f029be45..6096349cf8c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -15546,6 +15546,50 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FileCheck extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Kt53261 extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class StringConcatenationTypeNarrowing extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index af2c13e7137..4a9ef08d7b3 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -13904,6 +13904,42 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java index 4704ce48b55..5002c668473 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java @@ -13904,6 +13904,42 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") 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 12118149014..81af4c0edca 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 @@ -13904,6 +13904,42 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 9c3c5edb16d..6a330bcb662 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -13904,6 +13904,42 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 078199704d8..8487e9b8817 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -5916,24 +5916,7 @@ Task fileCheckTest(String name, Closure configureClosure) { } } -fileCheckTest("filecheck_smoke0") { - annotatedSource = project.file('filecheck/smoke0.kt') -} - -fileCheckTest("filecheck_when") { - annotatedSource = project.file('filecheck/when.kt') -} - if (HostManager.@Companion.hostIsMac) { - fileCheckTest("filecheck_force_arm_instruction_set") { - enabled = enabled && cacheTesting == null - annotatedSource = project.file('filecheck/force_arm_instruction_set.kt') - targetName = "watchos_arm32" - // Perform check after optimization pipeline because - // LLVM might infer attributes. - phaseToCheck = "LTOBitcodeOptimization" - } - fileCheckTest("filecheck_redundant_safepoints_removal_smallbinary") { enabled = project.globalTestArgs.contains("-opt") annotatedSource = project.file('filecheck/redundant_safepoints.kt') @@ -5953,242 +5936,6 @@ fileCheckTest("filecheck_redundant_safepoints_removal") { phaseToCheck = "RemoveRedundantSafepoints" } -fileCheckTest("filecheck_replace_invoke_with_call") { - annotatedSource = project.file('filecheck/replace_invoke_with_call.kt') -} - -fileCheckTest("filecheck_no_frame_on_constant_object_access") { - annotatedSource = project.file('filecheck/no_frame_on_constant_object_access.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_simple_function_reference") { - annotatedSource = project.file('filecheck/kt49847_simple_function_reference.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_sam_Any") { - annotatedSource = project.file('filecheck/kt49847_sam_Any.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_sam_Int") { - annotatedSource = project.file('filecheck/kt49847_sam_Int.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_sam_Any_generic") { - annotatedSource = project.file('filecheck/kt49847_sam_Any_generic.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_sam_Int_generic") { - annotatedSource = project.file('filecheck/kt49847_sam_Int_generic.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_class") { - annotatedSource = project.file('filecheck/kt49847_class.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_generic") { - annotatedSource = project.file('filecheck/kt49847_generic.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt49847_generic_receiver") { - annotatedSource = project.file('filecheck/kt49847_generic_receiver.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt58654") { - annotatedSource = project.file('filecheck/kt58654.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_inline_unbox") { - annotatedSource = project.file('filecheck/kt53261/kt53261_inline_unbox.kt') - enabled = project.globalTestArgs.contains('-opt') - if (isAppleTarget(project)) { - checkPrefix = "CHECK-APPLE" - } -} - -fileCheckTest("filecheck_kt53261_noinline_value_unbox") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_value_unbox.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_CPointer.kt") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_CPointer.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_NativePointed.kt") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_NativePointed.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_NonNullNativePtr.kt") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_NonNullNativePtr.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_StableRef") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_StableRef.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_UByteArray.kt") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_UByteArray.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_UIntArray.kt") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_UIntArray.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_ULongArray.kt") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_ULongArray.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_kt53261_noinline_UShortArray.kt") { - annotatedSource = project.file('filecheck/kt53261/kt53261_noinline_UShortArray.kt') - enabled = project.globalTestArgs.contains('-opt') -} - -fileCheckTest("filecheck_intrinsics") { - annotatedSource = project.file('filecheck/intrinsics.kt') -} - -fileCheckTest("filecheck_default_parameters_dont_box") { - annotatedSource = project.file('filecheck/default_parameters_dont_box.kt') -} - -tasks.register("kt53119_side_effect", KonanLocalTest) { - useGoldenData = true - source = "codegen/stringConcatenationTypeNarrowing/kt53119_side_effect.kt" -} - -fileCheckTest("filecheck_kt53119_plus_generated_noescape") { - annotatedSource = project.file('codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt') - enabled = project.globalTestArgs.contains('-opt') - extraOpts = ["-tr"] -} - -tasks.register("kt53119_plus_generated_noescape", KonanLocalTest) { - useGoldenData = true - source = "codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt" -} - -fileCheckTest("filecheck_kt53119_plus_member") { - annotatedSource = project.file('codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.kt') - enabled = project.globalTestArgs.contains('-opt') - extraOpts = ["-tr"] -} - -tasks.register("kt53119_plus_member", KonanLocalTest) { - useGoldenData = true - source = "codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.kt" -} - -fileCheckTest("filecheck_kt53119_plus_extension") { - annotatedSource = project.file('codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt') - enabled = project.globalTestArgs.contains('-opt') - extraOpts = ["-tr"] -} - -tasks.register("kt53119_plus_extension", KonanLocalTest) { - useGoldenData = true - source = "codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt" -} - -fileCheckTest("filecheck_kt53119_append_generated") { - annotatedSource = project.file('codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.kt') - enabled = project.globalTestArgs.contains('-opt') - extraOpts = ["-tr"] -} - -tasks.register("kt53119_append_generated", KonanLocalTest) { - useGoldenData = true - source = "codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.kt" -} - -fileCheckTest("filecheck_kt53119_append_manual") { - annotatedSource = project.file('codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.kt') - enabled = project.globalTestArgs.contains('-opt') - extraOpts = ["-tr"] -} - -tasks.register("kt53119_append_manual", KonanLocalTest) { - useGoldenData = true - source = "codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.kt" -} - -fileCheckTest("filecheck_escape_analysis_enabled") { - annotatedSource = project.file('filecheck/escape_analysis.kt') - enabled = project.globalTestArgs.contains('-opt') - checkPrefix = "CHECK-OPT" -} - -fileCheckTest("filecheck_enum_when") { - // In case of `-opt` we inline Enum.ordinal due to property inlining. - if (project.globalTestArgs.contains('-opt')) { - checkPrefix = "CHECK-OPT" - } - annotatedSource = project.file('filecheck/enum_when.kt') -} - -fileCheckTest("filecheck_escape_analysis_disabled") { - annotatedSource = project.file('filecheck/escape_analysis.kt') - enabled = project.globalTestArgs.contains('-g') - checkPrefix = "CHECK-DEBUG" -} - -fileCheckTest("filecheck_suspend_returnNothing") { - annotatedSource = project.file('filecheck/suspend_returnNothing.kt') -} - -fileCheckTest("filecheck_suspend_tailcalls_functions") { - annotatedSource = project.file('filecheck/suspend_tailcalls_functions.kt') -} - -fileCheckTest("filecheck_suspend_tailcalls_lambdas") { - annotatedSource = project.file('filecheck/suspend_tailcalls_lambdas.kt') -} - -fileCheckTest("filecheck_bce") { - enabled = enabled && cacheTesting == null - annotatedSource = project.file('filecheck/bce.kt') -} - -fileCheckTest("filecheck_generic_function_references") { - enabled = project.globalTestArgs.contains('-opt') - annotatedSource = project.file('filecheck/generic_function_references.kt') -} - -fileCheckTest("filecheck_adopted_function_reference") { - annotatedSource = project.file('filecheck/adopted_function_reference.kt') -} - -fileCheckTest("filecheck_single_tls_load") { - enabled = project.globalTestArgs.contains("-opt") - annotatedSource = project.file('filecheck/single_tls_load.kt') - phaseToCheck = "OptimizeTLSDataLoads" -} - -fileCheckTest("filecheck_signext_zeroext0") { - annotatedSource = project.file('filecheck/signext_zeroext0.kt') - if (project.testTarget == 'mingw_x64') { - checkPrefix = "CHECK-WINDOWSX64" - } else if (!target.family.appleFamily && target.architecture == Architecture.ARM64) { - checkPrefix = "CHECK-AAPCS" - } -} - createInterop("filecheck_signext_zeroext_interop_input") { it.defFile 'filecheck/signext_zeroext_interop_input.def' } @@ -6210,17 +5957,6 @@ fileCheckTest("filecheck_signext_zeroext_objc_export") { enabled = target.family.appleFamily } -fileCheckTest("filecheck_function_attributes_at_callsite") { - // attributes for caller and callee might be the same so we allow overlapping. - additionalFileCheckFlags = ["--allow-deprecated-dag-overlap"] - annotatedSource = project.file('filecheck/function_attributes_at_callsite.kt') -} - -fileCheckTest("filecheck_constants_merge") { - annotatedSource = project.file('filecheck/constants_merge.kt') -} - - fileCheckTest("filecheck_objc_direct") { enabled = enabled && cacheTesting == null annotatedSource = project.file('filecheck/objc_direct.kt') @@ -6228,10 +5964,6 @@ fileCheckTest("filecheck_objc_direct") { enabled = target.family.appleFamily } -fileCheckTest("filecheck_atomics") { - annotatedSource = project.file('filecheck/atomics.kt') -} - dependencies { nopPluginApi kotlinCompilerModule diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.kt b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.kt deleted file mode 100644 index cf632b36966..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package codegen.stringConcatenationTypeNarrowing.kt53119_append_generated -import kotlin.test.* - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyMaybeAny -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK: ret %struct.ObjHeader* - -fun maybeAnyMaybeAny(maybeAny1: Any?, maybeAny2: Any?): String { - return "$maybeAny1,$maybeAny2" -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyMaybeString -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append -// CHECK: ret %struct.ObjHeader* - -fun maybeAnyMaybeString(maybeAny1: Any?, maybeString2: String?): String { - return "$maybeAny1,$maybeString2" -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyString -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append -// CHECK: ret %struct.ObjHeader* - -fun maybeAnyString(maybeAny1: Any?, string: String): String { - return "$maybeAny1,$string" -} - -data class Foo(val bar: Int) - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyFoo -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append -// CHECK: ret %struct.ObjHeader* - -fun maybeAnyFoo(maybeAny: Any?, foo: Foo): String { - return "$maybeAny,$foo" -} -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated#maybeAnyMaybeFoo -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_generated.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - - -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append -// CHECK: ret %struct.ObjHeader* - -fun maybeAnyMaybeFoo(maybeAny: Any?, foo: Foo?): String { - return "$maybeAny,$foo" -} -@Test -fun runTest() { - val foo = Foo(42) - println(maybeAnyMaybeAny(foo, foo)) - println(maybeAnyMaybeAny(null, null)) - println(maybeAnyMaybeString(foo, "bar")) - println(maybeAnyMaybeString(null, null)) - println(maybeAnyString(foo, "bar")) - println(maybeAnyString(null, "bar")) - println(maybeAnyFoo(foo, foo)) - println(maybeAnyFoo(null, foo)) - println(maybeAnyMaybeFoo(foo, foo)) - println(maybeAnyMaybeFoo(foo, null)) -} diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.out b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.out deleted file mode 100644 index dee9b413891..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_generated.out +++ /dev/null @@ -1,10 +0,0 @@ -Foo(bar=42),Foo(bar=42) -null,null -Foo(bar=42),bar -null,null -Foo(bar=42),bar -null,bar -Foo(bar=42),Foo(bar=42) -null,Foo(bar=42) -Foo(bar=42),Foo(bar=42) -Foo(bar=42),null diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.kt b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.kt deleted file mode 100644 index f2e88e11008..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.kt +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package codegen.stringConcatenationTypeNarrowing.kt53119_append_manual -import kotlin.test.* - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendMaybeAny(kotlin.Any?) -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK: ret %struct.ObjHeader* - -fun appendMaybeAny(maybeAny: Any?): String { - val sb = kotlin.text.StringBuilder() - sb.append(maybeAny) - return sb.toString() -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendAny(kotlin.Any) -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) - -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append -// CHECK: ret %struct.ObjHeader* - -fun appendAny(any: Any): String { - val sb = kotlin.text.StringBuilder() - sb.append(any) - return sb.toString() -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendMaybeString(kotlin.String?) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String - -// CHECK: ret %struct.ObjHeader* - -fun appendMaybeString(maybeStr: String?): String { - val sb = kotlin.text.StringBuilder() - sb.append(maybeStr) - return sb.toString() -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendString(kotlin.String) -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append - -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String - -// CHECK: ret %struct.ObjHeader* - -fun appendString(str: String): String { - val sb = kotlin.text.StringBuilder() - sb.append(str) - return sb.toString() -} - -data class Foo(val bar: Int) - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual#appendFoo(codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo) -// CHECK: %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_append_manual.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append(kotlin.String?) - -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK-NOT: %struct.ObjHeader* @"kfun:kotlin.text.StringBuilder#append -// CHECK: ret %struct.ObjHeader* - -fun appendFoo(foo: Foo): String { - val sb = kotlin.text.StringBuilder() - sb.append(foo) - return sb.toString() -} - -@Test -fun runTest() { - val foo = Foo(42) - println(appendMaybeAny(foo)) - println(appendMaybeAny(null)) - println(appendAny(foo)) - println(appendMaybeString("foo")) - println(appendMaybeString(null)) - println(appendString("foo")) - println(appendFoo(foo)) -} diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.out b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.out deleted file mode 100644 index 1d7e5b40704..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_append_manual.out +++ /dev/null @@ -1,7 +0,0 @@ -Foo(bar=42) -null -Foo(bar=42) -foo -null -foo -Foo(bar=42) diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt deleted file mode 100644 index 5fefa6dce57..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension -import kotlin.test.* - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#manualPlusExtensionAny -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" - -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl - -// CHECK: ret %struct.ObjHeader* - -fun manualPlusExtensionAny(maybeStr: String?, maybeAny: kotlin.Any?): kotlin.String = - maybeStr + maybeAny - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#manualPlusExtensionString -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl - -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: ret %struct.ObjHeader* - -fun manualPlusExtensionString(maybeStr: String?, str: String): kotlin.String = - maybeStr + str - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionAny -// CHECK-NOT: kfun:kotlin#plus__at__kotlin.String?(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: kfun:kotlin#plus__at__kotlin.String?(kotlin.Any?) -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" - -// CHECK: ret %struct.ObjHeader* - -fun generatedPlusExtensionAny(maybeStr: String?, maybeAny: Any?): String { - return "$maybeStr$maybeAny" -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionString -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl - -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: ret %struct.ObjHeader* - -fun generatedPlusExtensionString(maybeStr: String?, str: String): String { - return "$maybeStr$str" -} - -data class Foo(val bar: Int) - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionFoo -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String - -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl - -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: ret %struct.ObjHeader* - -fun generatedPlusExtensionFoo(maybeStr: String?, foo: Foo): String { - return "$maybeStr$foo" -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension#generatedPlusExtensionMaybeFoo -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_extension.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" - -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: ret %struct.ObjHeader* - -fun generatedPlusExtensionMaybeFoo(maybeStr: String?, foo: Foo?): String { - return "$maybeStr$foo" -} - -@Test -fun runTest() { - val foo = Foo(42) - println(manualPlusExtensionAny("foo", foo)) - println(manualPlusExtensionAny(null, null)) - println(manualPlusExtensionString("foo", "bar")) - println(manualPlusExtensionString(null, "bar")) - println(generatedPlusExtensionAny("foo", foo)) - println(generatedPlusExtensionAny(null, null)) - println(generatedPlusExtensionString("foo", "bar")) - println(generatedPlusExtensionString(null, "bar")) - println(generatedPlusExtensionFoo(null, Foo(42))) - println(generatedPlusExtensionMaybeFoo("foo", Foo(42))) - println(generatedPlusExtensionMaybeFoo("foo", null)) -} diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.out b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.out deleted file mode 100644 index 160fb91a0e9..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_extension.out +++ /dev/null @@ -1,11 +0,0 @@ -fooFoo(bar=42) -nullnull -foobar -nullbar -fooFoo(bar=42) -nullnull -foobar -nullbar -nullFoo(bar=42) -fooFoo(bar=42) -foonull diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.out b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.out deleted file mode 100644 index 2bbddb07247..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.out +++ /dev/null @@ -1 +0,0 @@ -42153 diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.kt b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.kt deleted file mode 100644 index 39800ac153b..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.kt +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package codegen.stringConcatenationTypeNarrowing.kt53119_plus_member -import kotlin.test.* - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberAny -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: ret %struct.ObjHeader* - -fun manualPlusMemberAny(str: String, maybeAny: kotlin.Any?): kotlin.String = - str + maybeAny - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberString -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" - -// CHECK: ret %struct.ObjHeader* - -fun manualPlusMemberString(str1: String, str2: String): kotlin.String = - str1 + str2 - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#generatedPlusMemberAny -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: ret %struct.ObjHeader* - -fun generatedPlusMemberAny(str: String, maybeAny: Any?): String { - return "$str$maybeAny" -} - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#generatedPlusMemberString -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: call %struct.ObjHeader* @Kotlin_String_plusImpl - -// CHECK-NOT: call %struct.ObjHeader* @"kfun:kotlin.String#toString(){}kotlin.String" -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) - -// CHECK: ret %struct.ObjHeader* - -fun generatedPlusMemberString(str1: String, str2: String): String { - return "$str1$str2" -} - -data class Foo(val bar: Int) - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberFoo -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) -// CHECK call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" -// CHECK-NOT Foo#toString(){}kotlin.String - -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) -// CHECK-NOT: Foo#toString(){}kotlin.String" - -// CHECK: ret %struct.ObjHeader* -fun manualPlusMemberFoo(str1: String, foo: Foo): kotlin.String = - str1 + foo - -// CHECK-LABEL: define %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member#manualPlusMemberMaybeFoo -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) -// CHECK call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString(){}kotlin.String" -// CHECK-NOT Foo#toString(){}kotlin.String - -// CHECK: call %struct.ObjHeader* @"kfun:codegen.stringConcatenationTypeNarrowing.kt53119_plus_member.Foo#toString -// CHECK-NOT: Foo#toString(){}kotlin.String" -// CHECK-NOT: kfun:kotlin.String#plus(kotlin.Any?) -// CHECK: call %struct.ObjHeader* @Kotlin_String_plusImpl -// CHECK-NOT: Foo#toString(){}kotlin.String" - -// CHECK: ret %struct.ObjHeader* -fun manualPlusMemberMaybeFoo(str1: String, foo: Foo?): kotlin.String = - str1 + foo - -@Test -fun runTest() { - val foo = Foo(42) - println(manualPlusMemberAny("foo", foo)) - println(manualPlusMemberAny("foo", null)) - println(manualPlusMemberString("foo", "bar")) - println(generatedPlusMemberAny("foo", null)) - println(generatedPlusMemberAny("foo", foo)) - println(generatedPlusMemberString("foo", "bar")) - println(manualPlusMemberFoo("foo", Foo(42))) - println(manualPlusMemberMaybeFoo("foo", Foo(42))) - println(manualPlusMemberMaybeFoo("foo", null)) -} diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.out b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.out deleted file mode 100644 index 3c25d8a8c10..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_plus_member.out +++ /dev/null @@ -1,9 +0,0 @@ -fooFoo(bar=42) -foonull -foobar -foonull -fooFoo(bar=42) -foobar -fooFoo(bar=42) -fooFoo(bar=42) -foonull diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_side_effect.kt b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_side_effect.kt deleted file mode 100644 index c45f8b2d51b..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_side_effect.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// The same tests are also tested with FileCheck in folder ../../filecheck/kt53119_*.kt -// Please keep them in sync - -package codegen.stringConcatenationTypeNarrowing.kt53119_side_effect -import kotlin.test.* - -fun withSideEffect(): String? { - println("Side effect") - return "Result." -} - -@Test -fun runTest() { - println("Retval is: " + withSideEffect()) - println("Retval is: " + withSideEffect() + "!") - println(withSideEffect() + withSideEffect()) - println(withSideEffect() + withSideEffect() + withSideEffect()) -} diff --git a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_side_effect.out b/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_side_effect.out deleted file mode 100644 index b497d6d6bab..00000000000 --- a/kotlin-native/backend.native/tests/codegen/stringConcatenationTypeNarrowing/kt53119_side_effect.out +++ /dev/null @@ -1,11 +0,0 @@ -Side effect -Retval is: Result. -Side effect -Retval is: Result.! -Side effect -Side effect -Result.Result. -Side effect -Side effect -Side effect -Result.Result.Result. diff --git a/kotlin-native/backend.native/tests/filecheck/adopted_function_reference.kt b/kotlin-native/backend.native/tests/filecheck/adopted_function_reference.kt deleted file mode 100644 index 1334f9070b8..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/adopted_function_reference.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -inline fun foo(x: () -> Unit): String { - x() - return "OK" -} - -fun String.id(s: String = this, vararg xs: Int): String = s - -// CHECK-LABEL: "kfun:#main(){}" -fun main() { - // CHECK-LABEL: entry - // CHECK-NOT: call %struct.ObjHeader* @AllocInstance - // CHECK-NOT: alloca - val x = foo("Fail"::id) - println(x) - // CHECK-LABEL: epilogue -} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/escape_analysis.kt b/kotlin-native/backend.native/tests/filecheck/escape_analysis.kt deleted file mode 100644 index cb4ffb92871..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/escape_analysis.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -class A(val x: Int) - -// CHECK-LABEL: "kfun:#main(){}" -fun main() { - // CHECK-DEBUG: call %struct.ObjHeader* @AllocInstance - // CHECK-OPT: alloca %"kclassbody:A#internal" - val a = A(5) - println(a.x) -// CHECK-LABEL: epilogue -} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_class.kt b/kotlin-native/backend.native/tests/filecheck/kt49847_class.kt deleted file mode 100644 index c54ff9878db..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_class.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -class C { - fun foo(x: Int) = x -} - -// CHECK-LABEL: define void @"kfun:#main(){}"() -// CHECK-NOT: Int-box -// CHECK-NOT: Int-unbox -// CHECK: ret void -fun main() { - val c = C() - val fooref = c::foo - if( fooref(42) == 42) - println("ok") -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_generic.kt b/kotlin-native/backend.native/tests/filecheck/kt49847_generic.kt deleted file mode 100644 index 5a7e8930487..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_generic.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -class C { - fun foo(x: T) = x -} - -// CHECK-LABEL: define void @"kfun:#main(){}"() -// CHECK-NOT: Int-box -// CHECK-NOT: Int-unbox -// CHECK: ret void -fun main() { - val c = C() - val fooref = c::foo - if( fooref(42) == 42) - println("ok") -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Any.kt b/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Any.kt deleted file mode 100644 index 9e712f2f203..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Any.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -fun interface Foo { - fun bar(x: Int): Any -} - -fun baz(x: Any): Int = x.hashCode() - -// CHECK-LABEL: define void @"kfun:#main(){}"() -// Boxing needs to be used now due to non-devirtualized call -// CHECK: Int-box - -// CHECK-NOT: Int-box -// CHECK-NOT: Int-unbox -// CHECK: ret void - -fun main() { - val foo: Foo = Foo(::baz) - if( foo.bar(42) == 42 ) - println("passed") -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Any_generic.kt b/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Any_generic.kt deleted file mode 100644 index f249072c1e3..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Any_generic.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -fun interface Foo { - fun bar(x: T): Any -} - -fun baz(x: Any): Int = x.hashCode() - -// CHECK-LABEL: define void @"kfun:#main(){}"() -// CHECK-NOT: Int-box -// CHECK-NOT: Int-unbox -// CHECK: ret void -fun main() { - val foo: Foo = Foo(::baz) - if( foo.bar(42) == 42 ) - println("passed") -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Int.kt b/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Int.kt deleted file mode 100644 index 0803c1aa511..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Int.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -fun interface Foo { - fun bar(x: Int): Int -} - -fun baz(x: Int): Int = x.hashCode() - -// CHECK-LABEL: define void @"kfun:#main(){}"() -// CHECK-NOT: Int-box -// CHECK-NOT: Int-unbox -// CHECK: ret void -fun main() { - val foo: Foo = Foo(::baz) - if( foo.bar(42) == 42 ) - println("passed") -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Int_generic.kt b/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Int_generic.kt deleted file mode 100644 index fa47a4c4e88..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_sam_Int_generic.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -fun interface Foo { - fun bar(x: T): Int -} - -fun baz(x: Any): Int = x.hashCode() - -// CHECK-LABEL: define void @"kfun:#main(){}"() -// CHECK-NOT: Int-box -// CHECK-NOT: Int-unbox -// CHECK: ret void -fun main() { - val foo: Foo = Foo(::baz) - if( foo.bar(42) == 42 ) - println("passed") -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt49847_simple_function_reference.kt b/kotlin-native/backend.native/tests/filecheck/kt49847_simple_function_reference.kt deleted file mode 100644 index 3bb5bf3f816..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt49847_simple_function_reference.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -fun plus1(x: Int) = x + 1 - -// CHECK-LABEL: define void @"kfun:#main(){}"() -// CHECK-NOT: Int-box -// CHECK-NOT: Int-unbox -// CHECK: ret void -fun main() { - val ref = ::plus1 - var y = 0 - repeat(100000) { - y += ref(it) // Should be devirtualized and invoked without boxing/unboxing (`Int-box`/`Int-unbox`) - } - if (y > 999999) - println("y > 999999") -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_inline_unbox.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_inline_unbox.kt deleted file mode 100644 index 73bb35b4c12..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_inline_unbox.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -import kotlin.native.concurrent.* -import kotlinx.cinterop.* - -fun main(arr: Array) { - println(arr.size.toByte() == arr[0].toByte()) - println(arr.size.toUByte() == arr[0].toUByte()) - println(arr.size.toShort() == arr[0].toShort()) - println(arr.size.toUShort() == arr[0].toUShort()) - println(arr.size.toInt() == arr[0].toInt()) - println(arr.size.toUInt() == arr[0].toUInt()) - println(arr.size.toLong() == arr[0].toLong()) - println(arr.size.toULong() == arr[0].toULong()) - println(arr.size.toFloat() == arr[0].toFloat()) - println(arr.size.toDouble() == arr[0].toDouble()) - println(Char(arr.size) == arr[0][0]) - println((arr.size == 1) == (arr[0] == "1")) // Boolean - - memScoped { - val var1: IntVar = alloc() - val var2: IntVar = alloc() - println(var1.ptr.rawValue == var2.ptr.rawValue) - } - - println(Result.success(arr.size) == Result.success(arr[0].toInt())) - println(vectorOf(arr.size, arr.size, arr.size, arr.size) == vectorOf(arr[0].toInt(), arr[0].toInt(), arr[0].toInt(), arr[0].toInt())) - - val w1 = Worker.start() - val w2 = Worker.start() - println(w1 == w2) - - val f1 = w1.requestTermination() - val f2 = w2.requestTermination() - println(f1 == f2) - - f1.result - f2.result -} -// CHECK-NOT: {{call|invoke}} i64 @"kfun:kotlin# -// CHECK-NOT: {{call|invoke}} i64 @"kfun:kotlin# - -// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin# -// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin# - -// CHECK-NOT: {{call|invoke}} signext i16 @"kfun:kotlin# -// CHECK-NOT: {{call|invoke}} zeroext i16 @"kfun:kotlin# - -// CHECK-NOT: {{call|invoke}} signext i8 @"kfun:kotlin# -// CHECK-NOT: {{call|invoke}} zeroext i8 @"kfun:kotlin# - -// CHECK-NOT: {{call|invoke}} zeroext i16 @"kfun:kotlin# -// CHECK-NOT: {{call|invoke}} zeroext i1 @"kfun:kotlin# - -// CHECK-NOT: {{call|invoke}} double @"kfun:kotlin# -// CHECK-NOT: {{call|invoke}} float @"kfun:kotlin# - -// CHECK-NOT: {{call|invoke}} i8* @"kfun:kotlin.native.internal# -// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin.native.concurrent# -// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin.native.concurrent# -// CHECK-NOT: {{call|invoke}} <4 x float> @"kfun:kotlin.native# -// CHECK-NOT: {{call|invoke}} %struct.ObjHeader* @"kfun:kotlin# - -// On APPLE targets, generated functions ToNSNumber may contain non-converted invocations of unbox functions. -// CHECK-APPLE: {{IntToNSNumber|LongToNSNumber|ByteToNSNumber|ShortToNSNumber|FloatToNSNumber|DoubleToNSNumber}} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_CPointer.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_CPointer.kt deleted file mode 100644 index dbe6f8aa708..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_CPointer.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -import kotlinx.cinterop.* - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:kotlinx.cinterop.CPointer#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) -// CHECK: call i8* @"kfun:kotlinx.cinterop#(kotlin.Any?){}kotlinx.cinterop.CPointer<-1:0>?" - -fun main() = memScoped { - val var1: IntVar = alloc() - val var2: IntVar = alloc() - println(var1.ptr == var2.ptr) -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_NativePointed.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_NativePointed.kt deleted file mode 100644 index b0e3f51aad3..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_NativePointed.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -import kotlinx.cinterop.* - -// CHECK-LABEL: define i8* @"kfun:kotlinx.cinterop#interpretOpaquePointed(kotlin.native.internal.NativePtr){}kotlinx.cinterop.NativePointed"(i8* %0) -// CHECK: call i8* @"kfun:kotlinx.cinterop#(kotlin.Any?){}kotlinx.cinterop.NativePointed?" - -fun main() = memScoped { - val var1: NativePointed = alloc(4, 4) - println(interpretOpaquePointed(var1.rawPtr)) -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_NonNullNativePtr.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_NonNullNativePtr.kt deleted file mode 100644 index 2b31026c130..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_NonNullNativePtr.kt +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -import kotlinx.cinterop.* - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:kotlin.native.internal.NonNullNativePtr#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) -// CHECK: call i8* @"kfun:kotlin.native.internal#(kotlin.Any?){}kotlin.native.internal.NonNullNativePtr?" - -fun main() = memScoped { - val var1: IntVar = alloc() - val var2: IntVar = alloc() - // The first one is K1, the second one is K2. - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") - println(var1.ptr.value as Any == var2.ptr.value as Any) -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_StableRef.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_StableRef.kt deleted file mode 100644 index 3a8a458cdc8..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_StableRef.kt +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -import kotlinx.cinterop.* - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:kotlinx.cinterop.StableRef#equals(kotlin.Any?){}kotlin.Boolean"(i8* %0, %struct.ObjHeader* %1) -// CHECK: call i8* @"kfun:kotlinx.cinterop#(kotlin.Any?){}kotlinx.cinterop.StableRef<-1:0>?" - -fun main() { - val ref1 = StableRef.create(Any()) - val ref2 = StableRef.create(Any()) - println(ref1 == ref2) - ref2.dispose() - ref1.dispose() -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UByteArray.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UByteArray.kt deleted file mode 100644 index 8f7c9407409..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UByteArray.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:kotlin.UByteArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) -// CHECK: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.UByteArray?" - -fun main() { - val arr1 = UByteArray(10) { it.toUByte() } - val arr2 = UByteArray(10) { (it / 2).toUByte() } - println(arr1 == arr2) -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UIntArray.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UIntArray.kt deleted file mode 100644 index 5ca01a4f5b3..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UIntArray.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:kotlin.UIntArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) -// CHECK: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.UIntArray?" - -fun main() { - val arr1 = UIntArray(10) { it.toUInt() } - val arr2 = UIntArray(10) { (it / 2).toUInt() } - println(arr1 == arr2) -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_ULongArray.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_ULongArray.kt deleted file mode 100644 index 64fa93b2817..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_ULongArray.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:kotlin.ULongArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) -// CHECK: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.ULongArray?" - -fun main() { - val arr1 = ULongArray(10) { it.toULong() } - val arr2 = ULongArray(10) { (it / 2).toULong() } - println(arr1 == arr2) -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UShortArray.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UShortArray.kt deleted file mode 100644 index aca0c2a743c..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_UShortArray.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:kotlin.UShortArray#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) -// CHECK: call %struct.ObjHeader* @"kfun:kotlin#(kotlin.Any?){}kotlin.UShortArray?" - -fun main() { - val arr1 = UShortArray(10) { it.toUShort() } - val arr2 = UShortArray(10) { (it / 2).toUShort() } - println(arr1 == arr2) -} diff --git a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_value_unbox.kt b/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_value_unbox.kt deleted file mode 100644 index ffd05dffd44..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/kt53261/kt53261_noinline_value_unbox.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: define {{zeroext i1|i1}} @"kfun:C#equals(kotlin.Any?){}kotlin.Boolean"(%struct.ObjHeader* %0, %struct.ObjHeader* %1) -// CHECK: call %struct.ObjHeader* @"kfun:#(kotlin.Any?){}C?" -value class C(val x: Any) -// Note: is also called from bridges for equals, hashCode and toString. - -fun main() { - println(C(42) == C(13)) -} diff --git a/kotlin-native/backend.native/tests/filecheck/signext_zeroext0.kt b/kotlin-native/backend.native/tests/filecheck/signext_zeroext0.kt deleted file mode 100644 index 4948aa96d85..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/signext_zeroext0.kt +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext %0) -// CHECK-LABEL-AAPCS: i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 %0) -// CHECK-LABEL-WINDOWSX64: zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext %0) -fun id(arg: Boolean): Boolean { - return arg -} - -// CHECK-LABEL: signext i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 signext %0) -// CHECK-LABEL-AAPCS: i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 %0) -// CHECK-LABEL-WINDOWSX64: i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 %0) -fun id(arg: Byte): Byte { - return arg -} - -// CHECK-LABEL: zeroext i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 zeroext %0) -// CHECK-LABEL-AAPCS: i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 %0) -// CHECK-LABEL-WINDOWSX64: i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 %0) -fun id(arg: Char): Char { - return arg -} - -// CHECK-LABEL: signext i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 signext %0) -// CHECK-LABEL-AAPCS: i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 %0) -// CHECK-LABEL-WINDOWSX64: i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 %0) -fun id(arg: Short): Short { - return arg -} - -// CHECK-LABEL: i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 %0) -// CHECK-LABEL-AAPCS: i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 %0) -// CHECK-LABEL-WINDOWSX64: i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 %0) -fun id(arg: Int): Int { - return arg -} - -// CHECK-LABEL: i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 %0) -// CHECK-LABEL-AAPCS: i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 %0) -// CHECK-LABEL-WINDOWSX64: i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 %0) -fun id(arg: Long): Long { - return arg -} - -// CHECK-LABEL: float @"kfun:#id(kotlin.Float){}kotlin.Float"(float %0) -// CHECK-LABEL-AAPCS: float @"kfun:#id(kotlin.Float){}kotlin.Float"(float %0) -// CHECK-LABEL-WINDOWSX64: float @"kfun:#id(kotlin.Float){}kotlin.Float"(float %0) -fun id(arg: Float): Float { - return arg -} - -// CHECK-LABEL: double @"kfun:#id(kotlin.Double){}kotlin.Double"(double %0) -// CHECK-LABEL-AAPCS: double @"kfun:#id(kotlin.Double){}kotlin.Double"(double %0) -// CHECK-LABEL-WINDOWSX64: double @"kfun:#id(kotlin.Double){}kotlin.Double"(double %0) -fun id(arg: Double): Double { - return arg -} - -// CHECK-LABEL: define zeroext i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 zeroext %0) -// CHECK-LABEL-AAPCS: define i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 %0) -// CHECK-LABEL-WINDOWSX64: define i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 %0) -fun id(arg: UByte): UByte { - return arg -} - -// CHECK-LABEL: define zeroext i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 zeroext %0) -// CHECK-LABEL-AAPCS: define i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 %0) -// CHECK-LABEL-WINDOWSX64: define i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 %0) -fun id(arg: UShort): UShort { - return arg -} - -// CHECK-LABEL: define i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 %0) -// CHECK-LABEL-AAPCS: define i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 %0) -// CHECK-LABEL-WINDOWSX64: define i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 %0) -fun id(arg: UInt): UInt { - return arg -} - -// CHECK-LABEL: define i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 %0) -// CHECK-LABEL-AAPCS: define i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 %0) -// CHECK-LABEL-WINDOWSX64: define i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 %0) -fun id(arg: ULong): ULong { - return arg -} - -fun checkPrimitives() { - // CHECK: call zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext {{.*}}) - // CHECK-AAPCS: call i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 {{.*}}) - // CHECK-WINDOWSX64: call zeroext i1 @"kfun:#id(kotlin.Boolean){}kotlin.Boolean"(i1 zeroext {{.*}}) - id(true) - // CHECK: call signext i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 signext {{.*}}) - // CHECK-AAPCS: call i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 {{.*}}) - // CHECK-WINDOWSX64: call i8 @"kfun:#id(kotlin.Byte){}kotlin.Byte"(i8 {{.*}}) - id(0.toByte()) - // CHECK: call zeroext i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 zeroext {{.*}}) - // CHECK-AAPCS: call i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 {{.*}}) - // CHECK-WINDOWSX64: call i16 @"kfun:#id(kotlin.Char){}kotlin.Char"(i16 {{.*}}) - id('a') - // CHECK: call signext i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 signext {{.*}}) - // CHECK-AAPCS: call i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 {{.*}}) - // CHECK-WINDOWSX64: call i16 @"kfun:#id(kotlin.Short){}kotlin.Short"(i16 {{.*}}) - id(0.toShort()) - // CHECK: call i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 {{.*}}) - // CHECK-AAPCS: call i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 {{.*}}) - // CHECK-WINDOWSX64: call i32 @"kfun:#id(kotlin.Int){}kotlin.Int"(i32 {{.*}}) - id(0) - // CHECK: call i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 {{.*}}) - // CHECK-AAPCS: call i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 {{.*}}) - // CHECK-WINDOWSX64: call i64 @"kfun:#id(kotlin.Long){}kotlin.Long"(i64 {{.*}}) - id(0L) - // CHECK: call float @"kfun:#id(kotlin.Float){}kotlin.Float"(float {{.*}}) - // CHECK-AAPCS: call float @"kfun:#id(kotlin.Float){}kotlin.Float"(float {{.*}}) - // CHECK-WINDOWSX64: call float @"kfun:#id(kotlin.Float){}kotlin.Float"(float {{.*}}) - id(0.5f) - // CHECK: call double @"kfun:#id(kotlin.Double){}kotlin.Double"(double {{.*}}) - // CHECK-AAPCS: call double @"kfun:#id(kotlin.Double){}kotlin.Double"(double {{.*}}) - // CHECK-WINDOWSX64: call double @"kfun:#id(kotlin.Double){}kotlin.Double"(double {{.*}}) - id(0.5) - // CHECK: call zeroext i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 zeroext {{.*}}) - // CHECK-AAPCS: call i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 {{.*}}) - // CHECK-WINDOWSX64: call i8 @"kfun:#id(kotlin.UByte){}kotlin.UByte"(i8 {{.*}}) - id(0.toUByte()) - // CHECK: call zeroext i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 zeroext {{.*}}) - // CHECK-AAPCS: call i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 {{.*}}) - // CHECK-WINDOWSX64: call i16 @"kfun:#id(kotlin.UShort){}kotlin.UShort"(i16 {{.*}}) - id(0.toUShort()) - // CHECK: call i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 {{.*}}) - // CHECK-AAPCS: call i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 {{.*}}) - // CHECK-WINDOWSX64: call i32 @"kfun:#id(kotlin.UInt){}kotlin.UInt"(i32 {{.*}}) - id(15u) - // CHECK: call i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 {{.*}}) - // CHECK-AAPCS: call i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 {{.*}}) - // CHECK-WINDOWSX64: call i64 @"kfun:#id(kotlin.ULong){}kotlin.ULong"(i64 {{.*}}) - id(15uL) -} - -value class CharWrapper(val ch: Char) - -// CHECK-LABEL: zeroext i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 zeroext %0) -// CHECK-LABEL-AAPCS: i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 %0) -// CHECK-LABEL-WINDOWSX64: i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 %0) -fun id(arg: CharWrapper): CharWrapper { - return arg -} - -// Check that value classes doesn't affect parameter attributes - -fun checkInlineClasses() { - // CHECK: call zeroext i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 zeroext {{.*}}) - // CHECK-AAPCS: call i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 {{.*}}) - // CHECK-WINDOWSX64: call i16 @"kfun:#id(CharWrapper){}CharWrapper"(i16 {{.*}}) - id(CharWrapper('c')) -} - -// CHECK-LABEL: %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) -// CHECK-LABEL-AAPCS: %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) -// CHECK-LABEL-WINDOWSX64: %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) -fun nullableId(arg: Byte?): Byte? { - return arg -} - -// CHECK-LABEL: %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) -// CHECK-LABEL-AAPCS: %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) -// CHECK-LABEL-WINDOWSX64: %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* %0, %struct.ObjHeader** %1) -fun nullableId(arg: CharWrapper?): CharWrapper? { - return arg -} - -// Check that we don't pass primitive-specific attributes to their boxes -fun checkBoxes() { - // CHECK: call %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) - // CHECK-AAPCS: call %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) - // CHECK-WINDOWSX64: call %struct.ObjHeader* @"kfun:#nullableId(kotlin.Byte?){}kotlin.Byte?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) - nullableId(1.toByte()) - // CHECK: call %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) - // CHECK-AAPCS: call %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) - // CHECK-WINDOWSX64: call %struct.ObjHeader* @"kfun:#nullableId(CharWrapper?){}CharWrapper?"(%struct.ObjHeader* {{.*}}, %struct.ObjHeader** {{.*}}) - nullableId(CharWrapper('a')) -} - -// CHECK-LABEL: void @"kfun:#main(){}"() -// CHECK-LABEL-AAPCS: void @"kfun:#main(){}"() -// CHECK-LABEL-WINDOWSX64: void @"kfun:#main(){}"() -fun main() { - checkPrimitives() - checkInlineClasses() - checkBoxes() -} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/single_tls_load.kt b/kotlin-native/backend.native/tests/filecheck/single_tls_load.kt deleted file mode 100644 index 92e299fe153..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/single_tls_load.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -class Wrapper(x: Int) - -// CHECK-LABEL: "kfun:#f(kotlin.Int;kotlin.String){}kotlin.String" -fun f(x: Int, s: String): String { - // CHECK: _ZN6kotlin2mm14ThreadRegistry22currentThreadDataNode_E - // CHECK-NOT: _ZN6kotlin2mm14ThreadRegistry22currentThreadDataNode_E - if (x < 0) throw IllegalStateException() - if (x > 0) return f(x - 1, s) - val b = Wrapper(2) - val a = listOf(x, x, Wrapper(1), 2, x) - return buildString { - for (i in a) { appendLine("$s i") } - } -// CHECK: {{^}$}} -} - -fun main() { println(f(10, "123456")) } diff --git a/kotlin-native/backend.native/tests/filecheck/smoke0.kt b/kotlin-native/backend.native/tests/filecheck/smoke0.kt deleted file mode 100644 index 2426abc7912..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/smoke0.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -// CHECK-LABEL: "kfun:#id(kotlin.Any?){}kotlin.Any?" -fun id(a: Any?): Any? { - return a -// CHECK-LABEL: epilogue -} - -// CHECK-LABEL: "kfun:#main(){}" -fun main() { - // CHECK: call %struct.ObjHeader* @"kfun:#id(kotlin.Any?){}kotlin.Any?" - val x = id("Hello") - // CHECK: call void @"kfun:kotlin.io#println(kotlin.Any?){}"(%struct.ObjHeader* {{.*}}) - println(x) -// CHECK-LABEL: epilogue -} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/filecheck/when.kt b/kotlin-native/backend.native/tests/filecheck/when.kt deleted file mode 100644 index d5f2189f38b..00000000000 --- a/kotlin-native/backend.native/tests/filecheck/when.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -var i = 1 -fun main() { - println(when(i) { - 0 -> 10 - 1 -> 11 - 2 -> 12 - else -> 13 - }) -} -// CHECK-LABEL: define void @"kfun:#main(){}"() -// CHECK: when_case -// CHECK: when_next -// CHECK: when_case1 -// CHECK: when_next2 -// CHECK: when_case3 -// CHECK: when_next4 -// CHECK: when_exit -// CHECK: call void @"kfun:kotlin.io#println(kotlin.Any?) -// CHECK: ret void diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java index 6cd742b8593..d95dcb99264 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java @@ -15025,6 +15025,315 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + public class FileCheck { + @Test + @TestMetadata("adopted_function_reference.kt") + public void testAdopted_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/adopted_function_reference.kt"); + } + + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("atomics.kt") + public void testAtomics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/atomics.kt"); + } + + @Test + @TestMetadata("bce.kt") + public void testBce() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/bce.kt"); + } + + @Test + @TestMetadata("constants_merge.kt") + public void testConstants_merge() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/constants_merge.kt"); + } + + @Test + @TestMetadata("default_parameters_dont_box.kt") + public void testDefault_parameters_dont_box() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/default_parameters_dont_box.kt"); + } + + @Test + @TestMetadata("enum_when.kt") + public void testEnum_when() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/enum_when.kt"); + } + + @Test + @TestMetadata("escape_analysis.kt") + public void testEscape_analysis() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/escape_analysis.kt"); + } + + @Test + @TestMetadata("force_arm_instruction_set.kt") + public void testForce_arm_instruction_set() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/force_arm_instruction_set.kt"); + } + + @Test + @TestMetadata("function_attributes_at_callsite.kt") + public void testFunction_attributes_at_callsite() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/function_attributes_at_callsite.kt"); + } + + @Test + @TestMetadata("generic_function_references.kt") + public void testGeneric_function_references() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/generic_function_references.kt"); + } + + @Test + @TestMetadata("intrinsics.kt") + public void testIntrinsics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/intrinsics.kt"); + } + + @Test + @TestMetadata("kt49847_class.kt") + public void testKt49847_class() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_class.kt"); + } + + @Test + @TestMetadata("kt49847_generic.kt") + public void testKt49847_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic.kt"); + } + + @Test + @TestMetadata("kt49847_generic_receiver.kt") + public void testKt49847_generic_receiver() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic_receiver.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any.kt") + public void testKt49847_sam_Any() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any_generic.kt") + public void testKt49847_sam_Any_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any_generic.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int.kt") + public void testKt49847_sam_Int() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int_generic.kt") + public void testKt49847_sam_Int_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int_generic.kt"); + } + + @Test + @TestMetadata("kt49847_simple_function_reference.kt") + public void testKt49847_simple_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_simple_function_reference.kt"); + } + + @Test + @TestMetadata("kt58654.kt") + public void testKt58654() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt58654.kt"); + } + + @Test + @TestMetadata("no_frame_on_constant_object_access.kt") + public void testNo_frame_on_constant_object_access() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/no_frame_on_constant_object_access.kt"); + } + + @Test + @TestMetadata("replace_invoke_with_call.kt") + public void testReplace_invoke_with_call() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/replace_invoke_with_call.kt"); + } + + @Test + @TestMetadata("signext_zeroext0.kt") + public void testSignext_zeroext0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/signext_zeroext0.kt"); + } + + @Test + @TestMetadata("single_tls_load.kt") + public void testSingle_tls_load() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/single_tls_load.kt"); + } + + @Test + @TestMetadata("smoke0.kt") + public void testSmoke0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/smoke0.kt"); + } + + @Test + @TestMetadata("suspend_returnNothing.kt") + public void testSuspend_returnNothing() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_returnNothing.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_functions.kt") + public void testSuspend_tailcalls_functions() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_functions.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_lambdas.kt") + public void testSuspend_tailcalls_lambdas() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_lambdas.kt"); + } + + @Test + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/when.kt"); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53261_inline_unbox.kt") + public void testKt53261_inline_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_inline_unbox.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_CPointer.kt") + public void testKt53261_noinline_CPointer() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_CPointer.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NativePointed.kt") + public void testKt53261_noinline_NativePointed() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NativePointed.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NonNullNativePtr.kt") + public void testKt53261_noinline_NonNullNativePtr() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NonNullNativePtr.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_StableRef.kt") + public void testKt53261_noinline_StableRef() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_StableRef.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UByteArray.kt") + public void testKt53261_noinline_UByteArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UByteArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UIntArray.kt") + public void testKt53261_noinline_UIntArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UIntArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_ULongArray.kt") + public void testKt53261_noinline_ULongArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_ULongArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UShortArray.kt") + public void testKt53261_noinline_UShortArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UShortArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_value_unbox.kt") + public void testKt53261_noinline_value_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_value_unbox.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53119_append_generated.kt") + public void testKt53119_append_generated() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_generated.kt"); + } + + @Test + @TestMetadata("kt53119_append_manual.kt") + public void testKt53119_append_manual() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_manual.kt"); + } + + @Test + @TestMetadata("kt53119_plus_extension.kt") + public void testKt53119_plus_extension() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt"); + } + + @Test + @TestMetadata("kt53119_plus_generated_noescape.kt") + public void testKt53119_plus_generated_noescape() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt"); + } + + @Test + @TestMetadata("kt53119_plus_member.kt") + public void testKt53119_plus_member() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_member.kt"); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java index f570ffe2b2c..f846c988baa 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java @@ -15383,6 +15383,321 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class FileCheck { + @Test + @TestMetadata("adopted_function_reference.kt") + public void testAdopted_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/adopted_function_reference.kt"); + } + + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("atomics.kt") + public void testAtomics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/atomics.kt"); + } + + @Test + @TestMetadata("bce.kt") + public void testBce() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/bce.kt"); + } + + @Test + @TestMetadata("constants_merge.kt") + public void testConstants_merge() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/constants_merge.kt"); + } + + @Test + @TestMetadata("default_parameters_dont_box.kt") + public void testDefault_parameters_dont_box() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/default_parameters_dont_box.kt"); + } + + @Test + @TestMetadata("enum_when.kt") + public void testEnum_when() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/enum_when.kt"); + } + + @Test + @TestMetadata("escape_analysis.kt") + public void testEscape_analysis() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/escape_analysis.kt"); + } + + @Test + @TestMetadata("force_arm_instruction_set.kt") + public void testForce_arm_instruction_set() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/force_arm_instruction_set.kt"); + } + + @Test + @TestMetadata("function_attributes_at_callsite.kt") + public void testFunction_attributes_at_callsite() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/function_attributes_at_callsite.kt"); + } + + @Test + @TestMetadata("generic_function_references.kt") + public void testGeneric_function_references() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/generic_function_references.kt"); + } + + @Test + @TestMetadata("intrinsics.kt") + public void testIntrinsics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/intrinsics.kt"); + } + + @Test + @TestMetadata("kt49847_class.kt") + public void testKt49847_class() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_class.kt"); + } + + @Test + @TestMetadata("kt49847_generic.kt") + public void testKt49847_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic.kt"); + } + + @Test + @TestMetadata("kt49847_generic_receiver.kt") + public void testKt49847_generic_receiver() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic_receiver.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any.kt") + public void testKt49847_sam_Any() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any_generic.kt") + public void testKt49847_sam_Any_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any_generic.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int.kt") + public void testKt49847_sam_Int() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int_generic.kt") + public void testKt49847_sam_Int_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int_generic.kt"); + } + + @Test + @TestMetadata("kt49847_simple_function_reference.kt") + public void testKt49847_simple_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_simple_function_reference.kt"); + } + + @Test + @TestMetadata("kt58654.kt") + public void testKt58654() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt58654.kt"); + } + + @Test + @TestMetadata("no_frame_on_constant_object_access.kt") + public void testNo_frame_on_constant_object_access() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/no_frame_on_constant_object_access.kt"); + } + + @Test + @TestMetadata("replace_invoke_with_call.kt") + public void testReplace_invoke_with_call() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/replace_invoke_with_call.kt"); + } + + @Test + @TestMetadata("signext_zeroext0.kt") + public void testSignext_zeroext0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/signext_zeroext0.kt"); + } + + @Test + @TestMetadata("single_tls_load.kt") + public void testSingle_tls_load() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/single_tls_load.kt"); + } + + @Test + @TestMetadata("smoke0.kt") + public void testSmoke0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/smoke0.kt"); + } + + @Test + @TestMetadata("suspend_returnNothing.kt") + public void testSuspend_returnNothing() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_returnNothing.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_functions.kt") + public void testSuspend_tailcalls_functions() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_functions.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_lambdas.kt") + public void testSuspend_tailcalls_lambdas() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_lambdas.kt"); + } + + @Test + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/when.kt"); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53261_inline_unbox.kt") + public void testKt53261_inline_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_inline_unbox.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_CPointer.kt") + public void testKt53261_noinline_CPointer() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_CPointer.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NativePointed.kt") + public void testKt53261_noinline_NativePointed() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NativePointed.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NonNullNativePtr.kt") + public void testKt53261_noinline_NonNullNativePtr() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NonNullNativePtr.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_StableRef.kt") + public void testKt53261_noinline_StableRef() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_StableRef.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UByteArray.kt") + public void testKt53261_noinline_UByteArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UByteArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UIntArray.kt") + public void testKt53261_noinline_UIntArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UIntArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_ULongArray.kt") + public void testKt53261_noinline_ULongArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_ULongArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UShortArray.kt") + public void testKt53261_noinline_UShortArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UShortArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_value_unbox.kt") + public void testKt53261_noinline_value_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_value_unbox.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53119_append_generated.kt") + public void testKt53119_append_generated() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_generated.kt"); + } + + @Test + @TestMetadata("kt53119_append_manual.kt") + public void testKt53119_append_manual() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_manual.kt"); + } + + @Test + @TestMetadata("kt53119_plus_extension.kt") + public void testKt53119_plus_extension() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt"); + } + + @Test + @TestMetadata("kt53119_plus_generated_noescape.kt") + public void testKt53119_plus_generated_noescape() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt"); + } + + @Test + @TestMetadata("kt53119_plus_member.kt") + public void testKt53119_plus_member() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_member.kt"); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java index f6a3cfdb4b5..c2ef3cb2843 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java @@ -14847,6 +14847,312 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @DisabledTestsIfProperty(sourceLocations = { "compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt", "compiler/testData/codegen/box/multiplatform/defaultArguments/*.kt", "compiler/testData/codegen/box/multiplatform/migratedOldTests/*.kt", "compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt" }, property = ClassLevelProperty.TEST_MODE, propertyValue = "ONE_STAGE_MULTI_MODULE") + public class FileCheck { + @Test + @TestMetadata("adopted_function_reference.kt") + public void testAdopted_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/adopted_function_reference.kt"); + } + + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("atomics.kt") + public void testAtomics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/atomics.kt"); + } + + @Test + @TestMetadata("bce.kt") + public void testBce() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/bce.kt"); + } + + @Test + @TestMetadata("constants_merge.kt") + public void testConstants_merge() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/constants_merge.kt"); + } + + @Test + @TestMetadata("default_parameters_dont_box.kt") + public void testDefault_parameters_dont_box() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/default_parameters_dont_box.kt"); + } + + @Test + @TestMetadata("enum_when.kt") + public void testEnum_when() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/enum_when.kt"); + } + + @Test + @TestMetadata("escape_analysis.kt") + public void testEscape_analysis() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/escape_analysis.kt"); + } + + @Test + @TestMetadata("force_arm_instruction_set.kt") + public void testForce_arm_instruction_set() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/force_arm_instruction_set.kt"); + } + + @Test + @TestMetadata("function_attributes_at_callsite.kt") + public void testFunction_attributes_at_callsite() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/function_attributes_at_callsite.kt"); + } + + @Test + @TestMetadata("generic_function_references.kt") + public void testGeneric_function_references() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/generic_function_references.kt"); + } + + @Test + @TestMetadata("intrinsics.kt") + public void testIntrinsics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/intrinsics.kt"); + } + + @Test + @TestMetadata("kt49847_class.kt") + public void testKt49847_class() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_class.kt"); + } + + @Test + @TestMetadata("kt49847_generic.kt") + public void testKt49847_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic.kt"); + } + + @Test + @TestMetadata("kt49847_generic_receiver.kt") + public void testKt49847_generic_receiver() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic_receiver.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any.kt") + public void testKt49847_sam_Any() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any_generic.kt") + public void testKt49847_sam_Any_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any_generic.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int.kt") + public void testKt49847_sam_Int() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int_generic.kt") + public void testKt49847_sam_Int_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int_generic.kt"); + } + + @Test + @TestMetadata("kt49847_simple_function_reference.kt") + public void testKt49847_simple_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_simple_function_reference.kt"); + } + + @Test + @TestMetadata("kt58654.kt") + public void testKt58654() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt58654.kt"); + } + + @Test + @TestMetadata("no_frame_on_constant_object_access.kt") + public void testNo_frame_on_constant_object_access() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/no_frame_on_constant_object_access.kt"); + } + + @Test + @TestMetadata("replace_invoke_with_call.kt") + public void testReplace_invoke_with_call() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/replace_invoke_with_call.kt"); + } + + @Test + @TestMetadata("signext_zeroext0.kt") + public void testSignext_zeroext0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/signext_zeroext0.kt"); + } + + @Test + @TestMetadata("single_tls_load.kt") + public void testSingle_tls_load() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/single_tls_load.kt"); + } + + @Test + @TestMetadata("smoke0.kt") + public void testSmoke0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/smoke0.kt"); + } + + @Test + @TestMetadata("suspend_returnNothing.kt") + public void testSuspend_returnNothing() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_returnNothing.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_functions.kt") + public void testSuspend_tailcalls_functions() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_functions.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_lambdas.kt") + public void testSuspend_tailcalls_lambdas() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_lambdas.kt"); + } + + @Test + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/when.kt"); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @DisabledTestsIfProperty(sourceLocations = { "compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt", "compiler/testData/codegen/box/multiplatform/defaultArguments/*.kt", "compiler/testData/codegen/box/multiplatform/migratedOldTests/*.kt", "compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt" }, property = ClassLevelProperty.TEST_MODE, propertyValue = "ONE_STAGE_MULTI_MODULE") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53261_inline_unbox.kt") + public void testKt53261_inline_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_inline_unbox.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_CPointer.kt") + public void testKt53261_noinline_CPointer() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_CPointer.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NativePointed.kt") + public void testKt53261_noinline_NativePointed() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NativePointed.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NonNullNativePtr.kt") + public void testKt53261_noinline_NonNullNativePtr() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NonNullNativePtr.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_StableRef.kt") + public void testKt53261_noinline_StableRef() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_StableRef.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UByteArray.kt") + public void testKt53261_noinline_UByteArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UByteArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UIntArray.kt") + public void testKt53261_noinline_UIntArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UIntArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_ULongArray.kt") + public void testKt53261_noinline_ULongArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_ULongArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UShortArray.kt") + public void testKt53261_noinline_UShortArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UShortArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_value_unbox.kt") + public void testKt53261_noinline_value_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_value_unbox.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @DisabledTestsIfProperty(sourceLocations = { "compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt", "compiler/testData/codegen/box/multiplatform/defaultArguments/*.kt", "compiler/testData/codegen/box/multiplatform/migratedOldTests/*.kt", "compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt" }, property = ClassLevelProperty.TEST_MODE, propertyValue = "ONE_STAGE_MULTI_MODULE") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53119_append_generated.kt") + public void testKt53119_append_generated() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_generated.kt"); + } + + @Test + @TestMetadata("kt53119_append_manual.kt") + public void testKt53119_append_manual() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_manual.kt"); + } + + @Test + @TestMetadata("kt53119_plus_extension.kt") + public void testKt53119_plus_extension() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt"); + } + + @Test + @TestMetadata("kt53119_plus_generated_noescape.kt") + public void testKt53119_plus_generated_noescape() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt"); + } + + @Test + @TestMetadata("kt53119_plus_member.kt") + public void testKt53119_plus_member() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_member.kt"); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java index 5e22d07b13c..904188f47ac 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java @@ -15026,6 +15026,315 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class FileCheck { + @Test + @TestMetadata("adopted_function_reference.kt") + public void testAdopted_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/adopted_function_reference.kt"); + } + + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("atomics.kt") + public void testAtomics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/atomics.kt"); + } + + @Test + @TestMetadata("bce.kt") + public void testBce() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/bce.kt"); + } + + @Test + @TestMetadata("constants_merge.kt") + public void testConstants_merge() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/constants_merge.kt"); + } + + @Test + @TestMetadata("default_parameters_dont_box.kt") + public void testDefault_parameters_dont_box() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/default_parameters_dont_box.kt"); + } + + @Test + @TestMetadata("enum_when.kt") + public void testEnum_when() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/enum_when.kt"); + } + + @Test + @TestMetadata("escape_analysis.kt") + public void testEscape_analysis() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/escape_analysis.kt"); + } + + @Test + @TestMetadata("force_arm_instruction_set.kt") + public void testForce_arm_instruction_set() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/force_arm_instruction_set.kt"); + } + + @Test + @TestMetadata("function_attributes_at_callsite.kt") + public void testFunction_attributes_at_callsite() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/function_attributes_at_callsite.kt"); + } + + @Test + @TestMetadata("generic_function_references.kt") + public void testGeneric_function_references() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/generic_function_references.kt"); + } + + @Test + @TestMetadata("intrinsics.kt") + public void testIntrinsics() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/intrinsics.kt"); + } + + @Test + @TestMetadata("kt49847_class.kt") + public void testKt49847_class() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_class.kt"); + } + + @Test + @TestMetadata("kt49847_generic.kt") + public void testKt49847_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic.kt"); + } + + @Test + @TestMetadata("kt49847_generic_receiver.kt") + public void testKt49847_generic_receiver() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_generic_receiver.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any.kt") + public void testKt49847_sam_Any() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Any_generic.kt") + public void testKt49847_sam_Any_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Any_generic.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int.kt") + public void testKt49847_sam_Int() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int.kt"); + } + + @Test + @TestMetadata("kt49847_sam_Int_generic.kt") + public void testKt49847_sam_Int_generic() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_sam_Int_generic.kt"); + } + + @Test + @TestMetadata("kt49847_simple_function_reference.kt") + public void testKt49847_simple_function_reference() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt49847_simple_function_reference.kt"); + } + + @Test + @TestMetadata("kt58654.kt") + public void testKt58654() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt58654.kt"); + } + + @Test + @TestMetadata("no_frame_on_constant_object_access.kt") + public void testNo_frame_on_constant_object_access() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/no_frame_on_constant_object_access.kt"); + } + + @Test + @TestMetadata("replace_invoke_with_call.kt") + public void testReplace_invoke_with_call() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/replace_invoke_with_call.kt"); + } + + @Test + @TestMetadata("signext_zeroext0.kt") + public void testSignext_zeroext0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/signext_zeroext0.kt"); + } + + @Test + @TestMetadata("single_tls_load.kt") + public void testSingle_tls_load() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/single_tls_load.kt"); + } + + @Test + @TestMetadata("smoke0.kt") + public void testSmoke0() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/smoke0.kt"); + } + + @Test + @TestMetadata("suspend_returnNothing.kt") + public void testSuspend_returnNothing() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_returnNothing.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_functions.kt") + public void testSuspend_tailcalls_functions() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_functions.kt"); + } + + @Test + @TestMetadata("suspend_tailcalls_lambdas.kt") + public void testSuspend_tailcalls_lambdas() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/suspend_tailcalls_lambdas.kt"); + } + + @Test + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/when.kt"); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53261_inline_unbox.kt") + public void testKt53261_inline_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_inline_unbox.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_CPointer.kt") + public void testKt53261_noinline_CPointer() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_CPointer.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NativePointed.kt") + public void testKt53261_noinline_NativePointed() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NativePointed.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_NonNullNativePtr.kt") + public void testKt53261_noinline_NonNullNativePtr() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_NonNullNativePtr.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_StableRef.kt") + public void testKt53261_noinline_StableRef() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_StableRef.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UByteArray.kt") + public void testKt53261_noinline_UByteArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UByteArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UIntArray.kt") + public void testKt53261_noinline_UIntArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UIntArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_ULongArray.kt") + public void testKt53261_noinline_ULongArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_ULongArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_UShortArray.kt") + public void testKt53261_noinline_UShortArray() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_UShortArray.kt"); + } + + @Test + @TestMetadata("kt53261_noinline_value_unbox.kt") + public void testKt53261_noinline_value_unbox() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/kt53261/kt53261_noinline_value_unbox.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53119_append_generated.kt") + public void testKt53119_append_generated() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_generated.kt"); + } + + @Test + @TestMetadata("kt53119_append_manual.kt") + public void testKt53119_append_manual() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_append_manual.kt"); + } + + @Test + @TestMetadata("kt53119_plus_extension.kt") + public void testKt53119_plus_extension() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_extension.kt"); + } + + @Test + @TestMetadata("kt53119_plus_generated_noescape.kt") + public void testKt53119_plus_generated_noescape() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_generated_noescape.kt"); + } + + @Test + @TestMetadata("kt53119_plus_member.kt") + public void testKt53119_plus_member() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_plus_member.kt"); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestCase.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestCase.kt index 4941a85f6b8..5224519f00b 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestCase.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestCase.kt @@ -188,7 +188,8 @@ internal class TestCase( val freeCompilerArgs: TestCompilerArgs, val nominalPackageName: PackageName, val checks: TestRunChecks, - val extras: Extras + val extras: Extras, + val fileCheckStage: String? = null, // KT-62157: TODO move it to extras ) { sealed interface Extras class NoTestRunnerExtras(val entryPoint: String, val inputDataFile: File? = null, val arguments: List = emptyList()) : Extras diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestDirectives.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestDirectives.kt index 829e76da804..7f85b949f13 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestDirectives.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/TestDirectives.kt @@ -144,6 +144,10 @@ internal object TestDirectives : SimpleDirectivesContainer() { val FIR_IDENTICAL by directive( description = "Test behavior should be identical for FIR testing" ) + + val FILECHECK_STAGE by stringDirective( + description = "Specify a LLVM stage to dump LLVM IR after, and check it with LLVM FileCheck using its directives in test file" + ) } internal enum class TestKind { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt index 907ff8a3206..90a9d0b85c8 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilation.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.konan.properties.resolvablePropertyList import org.jetbrains.kotlin.konan.test.blackbox.support.* import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase.* import org.jetbrains.kotlin.konan.test.blackbox.support.TestModule.Companion.allDependsOn +import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ExecutableCompilation.Companion.applyFileCheckArgs import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ExecutableCompilation.Companion.applyPartialLinkageArgs import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ExecutableCompilation.Companion.applyTestRunnerSpecificArgs import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ExecutableCompilation.Companion.assertTestDumpFileNotEmptyIfExists @@ -362,6 +363,7 @@ internal class ExecutableCompilation( } } applyPartialLinkageArgs(partialLinkageConfig) + applyFileCheckArgs(expectedArtifact.fileCheckStage, expectedArtifact.fileCheckDump) super.applySpecificArgs(argsBuilder) } @@ -403,6 +405,13 @@ internal class ExecutableCompilation( add("-Xpartial-linkage-loglevel=${logLevel.name.lowercase()}") } } + + internal fun ArgsBuilder.applyFileCheckArgs(fileCheckStage: String?, fileCheckDump: File?) = + fileCheckStage?.let { + add("-Xllvm-variant=dev") // FileCheck utility is provided in `LLVM dev`, not `LLVM user` + add("-Xsave-llvm-ir-after=$it") + add("-Xsave-llvm-ir-directory=${fileCheckDump!!.parent}") + } } } @@ -464,6 +473,7 @@ internal class StaticCacheCompilation( add("-Xmake-per-file-cache") applyPartialLinkageArgs(partialLinkageConfig) + applyFileCheckArgs(expectedArtifact.fileCheckStage, expectedArtifact.fileCheckDump) } override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationArtifact.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationArtifact.kt index 98bf64d9a7d..6e97a8d9eaa 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationArtifact.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationArtifact.kt @@ -15,14 +15,22 @@ internal sealed interface TestCompilationArtifact { override val logFile: File get() = klibFile.resolveSibling("${klibFile.name}.log") } - data class KLIBStaticCache(val cacheDir: File, val klib: KLIB) : TestCompilationArtifact { + data class KLIBStaticCache(val cacheDir: File, val klib: KLIB, val fileCheckStage: String? = null) : TestCompilationArtifact { override val logFile: File get() = cacheDir.resolve("${klib.klibFile.nameWithoutExtension}-cache.log") + val fileCheckDump: File? + get() = fileCheckStage?.let { + cacheDir.resolveSibling("out.$it.ll") + } } - data class Executable(val executableFile: File) : TestCompilationArtifact { + data class Executable(val executableFile: File, val fileCheckStage: String? = null) : TestCompilationArtifact { val path: String get() = executableFile.path override val logFile: File get() = executableFile.resolveSibling("${executableFile.name}.log") val testDumpFile: File get() = executableFile.resolveSibling("${executableFile.name}.dump") + val fileCheckDump: File? + get() = fileCheckStage?.let { + executableFile.resolveSibling("out.$it.ll") + } } data class ObjCFramework(private val buildDir: File, val frameworkName: String) : TestCompilationArtifact { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt index 35a193402e9..f4c70aceaa6 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/compilation/TestCompilationFactory.kt @@ -117,7 +117,10 @@ internal class TestCompilationFactory { // Long pass. val freeCompilerArgs = rootModules.first().testCase.freeCompilerArgs // Should be identical inside the same test case group. val extras = testCases.first().extras // Should be identical inside the same test case group. - val executableArtifact = Executable(settings.artifactFileForExecutable(rootModules)) + val fileCheckStage = testCases.map { it.fileCheckStage }.singleOrNull() + if (fileCheckStage != null) + require(testCases.size == 1) { "FILECHECK-enabled test must be standalone" } + val executableArtifact = Executable(settings.artifactFileForExecutable(rootModules), fileCheckStage) val ( dependenciesToCompileExecutable: Iterable>, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt index 740d4a039b8..b1eb83f6609 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt @@ -21,6 +21,8 @@ import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.konan.test.blackbox.support.* import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase.WithTestRunnerExtras +import org.jetbrains.kotlin.konan.test.blackbox.support.TestDirectives.FILECHECK_STAGE +import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunChecks import org.jetbrains.kotlin.konan.test.blackbox.support.settings.* import org.jetbrains.kotlin.konan.test.blackbox.support.util.* @@ -75,6 +77,8 @@ internal class ExtTestCaseGroupProvider : TestCaseGroupProvider, TestDisposable( customKlibs = settings.get(), pipelineType = settings.get(), testMode = settings.get(), + cacheMode = settings.get(), + optimizationMode = settings.get(), timeouts = settings.get(), ) @@ -99,8 +103,10 @@ private class ExtTestDataFile( testRoots: TestRoots, private val generatedSources: GeneratedSources, private val customKlibs: CustomKlibs, - private val pipelineType: PipelineType, - private val testMode: TestMode, + pipelineType: PipelineType, + testMode: TestMode, + cacheMode: CacheMode, + optimizationMode: OptimizationMode, private val timeouts: Timeouts, ) { private val structure by lazy { @@ -144,6 +150,9 @@ private class ExtTestDataFile( && INCOMPATIBLE_DIRECTIVES.none { it in structure.directives } && structure.directives[API_VERSION_DIRECTIVE] !in INCOMPATIBLE_API_VERSIONS && structure.directives[LANGUAGE_VERSION_DIRECTIVE] !in INCOMPATIBLE_LANGUAGE_VERSIONS + && !(FILECHECK_STAGE.name in structure.directives + && (cacheMode as? CacheMode.WithStaticCache)?.useStaticCacheForUserLibraries == true) + && !(optimizationMode != OptimizationMode.OPT && structure.directives[FILECHECK_STAGE.name] == "OptimizeTLSDataLoads") && !(testDataFileSettings.languageSettings.contains("+${LanguageFeature.MultiPlatformProjects.name}") && pipelineType == PipelineType.K2 && testMode == TestMode.ONE_STAGE_MULTI_MODULE) @@ -194,7 +203,7 @@ private class ExtTestDataFile( val entryPointFunctionFQN = findEntryPoint() generateTestLauncher(isStandaloneTest, entryPointFunctionFQN) - return doCreateTestCase(isStandaloneTest, sharedModules) + return doCreateTestCase(settings, isStandaloneTest, sharedModules) } /** @@ -204,6 +213,7 @@ private class ExtTestDataFile( */ private fun determineIfStandaloneTest(): Boolean = with(structure) { if (directives.contains(NATIVE_STANDALONE_DIRECTIVE)) return true + if (directives.contains(FILECHECK_STAGE.name)) return true var isStandaloneTest = false @@ -502,6 +512,7 @@ private class ExtTestDataFile( } private fun doCreateTestCase( + settings: Settings, isStandaloneTest: Boolean, sharedModules: ThreadSafeCache ): TestCase = with(structure) { @@ -513,14 +524,16 @@ private class ExtTestDataFile( } } ) - + val fileCheckStage = retrieveFileCheckStage() val testCase = TestCase( id = TestCaseId.TestDataFile(testDataFile), kind = if (isStandaloneTest) TestKind.STANDALONE else TestKind.REGULAR, modules = modules, freeCompilerArgs = assembleFreeCompilerArgs(), nominalPackageName = testDataFileSettings.nominalPackageName, - checks = TestRunChecks.Default(timeouts.executionTimeout), + checks = TestRunChecks.Default(timeouts.executionTimeout) + .copy(fileCheckMatcher = fileCheckStage?.let { TestRunCheck.FileCheckMatcher(settings, testDataFile) }), + fileCheckStage = fileCheckStage, extras = WithTestRunnerExtras(runnerType = TestRunnerType.DEFAULT) ) testCase.initialize( @@ -531,6 +544,20 @@ private class ExtTestDataFile( return testCase } + private fun retrieveFileCheckStage(): String? { + val fileCheckStages = structure.directives.multiValues(FILECHECK_STAGE.name) + return when (fileCheckStages.size) { + 0 -> { + require(!isDirectiveDefined(testDataFile.readText(), FILECHECK_STAGE.name)) { + "In ${testDataFile.absolutePath}, one argument for FILECHECK directive is needed: LLVM stage name, to dump bitcode after" + } + null + } + 1 -> fileCheckStages.single() + else -> fail { "In ${testDataFile.absolutePath}, only one argument for FILECHECK directive is allowed: $fileCheckStages" } + } + } + companion object { private val INCOMPATIBLE_DIRECTIVES = setOf("FULL_JDK", "JVM_TARGET", "DIAGNOSTICS") diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/StandardTestCaseGroupProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/StandardTestCaseGroupProvider.kt index 6dd50b36872..3fb9ac2f0d4 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/StandardTestCaseGroupProvider.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/StandardTestCaseGroupProvider.kt @@ -227,7 +227,8 @@ internal class StandardTestCaseGroupProvider : TestCaseGroupProvider { computeExecutionTimeoutCheck(settings, expectedTimeoutFailure), computeExitCodeCheck(testKind, registeredDirectives, location), computeOutputDataFileCheck(testDataFile, registeredDirectives, location), - lldbSpec?.let { OutputMatcher { output -> lldbSpec.checkLLDBOutput(output, settings.get()) } } + lldbSpec?.let { OutputMatcher { output -> lldbSpec.checkLLDBOutput(output, settings.get()) } }, + fileCheckMatcher = null, ), extras = when (testKind) { TestKind.STANDALONE_NO_TR -> { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/AbstractLocalProcessRunner.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/AbstractLocalProcessRunner.kt index fc8e96c0799..0ccd7db7f4b 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/AbstractLocalProcessRunner.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/AbstractLocalProcessRunner.kt @@ -5,18 +5,22 @@ package org.jetbrains.kotlin.konan.test.blackbox.support.runner +import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.text.StringUtilRt.convertLineSeparators import kotlinx.coroutines.* +import org.jetbrains.kotlin.konan.target.Architecture +import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.konan.test.blackbox.support.runner.AbstractRunner.AbstractRun import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck.ExecutionTimeout import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck.ExitCode import org.jetbrains.kotlin.konan.test.blackbox.support.runner.UnfilteredProcessOutput.Companion.launchReader +import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeTargets +import org.jetbrains.kotlin.konan.test.blackbox.support.settings.OptimizationMode +import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables import org.jetbrains.kotlin.konan.test.blackbox.support.util.TestOutputFilter +import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly import org.junit.jupiter.api.Assertions.fail -import java.io.ByteArrayOutputStream -import java.io.IOException -import java.io.InputStream -import java.io.OutputStream +import java.io.* import java.util.concurrent.atomic.AtomicBoolean import kotlin.time.* @@ -43,7 +47,7 @@ internal abstract class AbstractLocalProcessRunner(protected val checks: Test val ignoreIOErrorsInProcessOutput = AtomicBoolean(false) val duration = measureTime { - process = ProcessBuilder(programArgs).directory(executable.executableFile.parentFile).start() + process = ProcessBuilder(programArgs).directory(executable.executable.executableFile.parentFile).start() customizeProcess(process) unfilteredOutputReader = launchReader( @@ -76,6 +80,7 @@ internal abstract class AbstractLocalProcessRunner(protected val checks: Test } RunResult( + testExecutable = executable, exitCode = exitCode, timeout = executionTimeout, duration = duration, @@ -140,6 +145,53 @@ internal abstract class LocalResultHandler( } } } + is TestRunCheck.FileCheckMatcher -> { + val fileCheckExecutable = check.settings.configurables.absoluteLlvmHome + File.separator + "bin" + File.separator + + if (SystemInfo.isWindows) "FileCheck.exe" else "FileCheck" + require(File(fileCheckExecutable).exists()) { + "$fileCheckExecutable does not exist. Make sure Distribution for `settings.configurables` " + + "was created using `propertyOverrides` to specify development variant of LLVM instead of user variant." + } + val fileCheckDump = runResult.testExecutable.executable.fileCheckDump!! + val fileCheckOut = File(fileCheckDump.absolutePath + ".out") + val fileCheckErr = File(fileCheckDump.absolutePath + ".err") + + val testTarget = check.settings.get().testTarget + val checkPrefixes = buildList { + add("CHECK") + add("CHECK-${testTarget.abiInfoString}") + add("CHECK-${testTarget.name.toUpperCaseAsciiOnly()}") + if (testTarget.family.isAppleFamily) { + add("CHECK-APPLE") + } + } + val optimizationMode = check.settings.get().name + val checkPrefixesWithOptMode = checkPrefixes.map { "$it-$optimizationMode" } + val commaSeparatedCheckPrefixes = (checkPrefixes + checkPrefixesWithOptMode).joinToString(",") + + val result = ProcessBuilder( + fileCheckExecutable, + check.testDataFile.absolutePath, + "--input-file", + fileCheckDump.absolutePath, + "--check-prefixes", commaSeparatedCheckPrefixes, + "--allow-deprecated-dag-overlap" // TODO specify it via new test directive for `function_attributes_at_callsite.kt` + ).redirectOutput(fileCheckOut) + .redirectError(fileCheckErr) + .start() + .waitFor() + val errText = fileCheckErr.readText() + val outText = fileCheckOut.readText() + verifyExpectation(result == 0 && errText.isEmpty() && outText.isEmpty()) { + val shortOutText = outText.lines().take(100) + val shortErrText = errText.lines().take(100) + "FileCheck matching of ${fileCheckDump.absolutePath}\n" + + "with '--check-prefixes $commaSeparatedCheckPrefixes'\n" + + "failed with result=$result:\n" + + shortOutText.joinToString("\n") + "\n" + + shortErrText.joinToString("\n") + } + } } } @@ -183,3 +235,11 @@ private class UnfilteredProcessOutput { } } } + +// Shameless borrowing `val KonanTarget.abiInfo` from module `:kotlin-native:backend.native`, which cannot be imported here for now. +val KonanTarget.abiInfoString: String + get() = when { + this == KonanTarget.MINGW_X64 -> "WINDOWSX64" + !family.isAppleFamily && architecture == Architecture.ARM64 -> "AAPCS" + else -> "DEFAULTABI" + } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestNameExtractor.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestNameExtractor.kt index 3d9ddff1208..0e424b4f8be 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestNameExtractor.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestNameExtractor.kt @@ -16,7 +16,7 @@ internal class LocalTestNameExtractor( checks: TestRunChecks ) : AbstractLocalProcessRunner>(checks) { override val visibleProcessName get() = "Test name extractor" - override val programArgs = listOf(executable.executableFile.path, "--ktest_list_tests") + override val programArgs = listOf(executable.executable.executableFile.path, "--ktest_list_tests") override val outputFilter get() = TestOutputFilter.NO_FILTERING override fun getLoggedParameters() = LoggedData.TestRunParameters( diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestRunner.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestRunner.kt index 6394800998d..8c657f57e35 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestRunner.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/LocalTestRunner.kt @@ -18,7 +18,7 @@ internal class LocalTestRunner(private val testRun: TestRun) : AbstractLocalProc override val executable get() = testRun.executable override val programArgs = buildList { - add(executable.executableFile.path) + add(executable.executable.executableFile.path) testRun.runParameters.forEach { it.applyTo(this) } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunResult.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunResult.kt index e446921eb47..85c5ee9d27a 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunResult.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunResult.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.util.TestOutputFilter import kotlin.time.Duration internal data class RunResult( + val testExecutable: TestExecutable, // KT-62157: TODO extract out of RunResult and pass Pair(TestExecutable, RunResult) val exitCode: Int?, val timeout: Duration, val duration: Duration, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunnerWithExecutor.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunnerWithExecutor.kt index a9f0c4ae1eb..bc4ef927004 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunnerWithExecutor.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/RunnerWithExecutor.kt @@ -41,7 +41,7 @@ internal class RunnerWithExecutor( val stdout = ByteArrayOutputStream() val stderr = ByteArrayOutputStream() val request = ExecuteRequest( - executableAbsolutePath = executable.executableFile.absolutePath, + executableAbsolutePath = executable.executable.executableFile.absolutePath, args = programArgs, stdin = stdin, stdout = stdout, @@ -50,6 +50,7 @@ internal class RunnerWithExecutor( ) val response = executor.execute(request) RunResult( + testExecutable = executable, exitCode = response.exitCode, timeout = request.timeout, duration = response.executionTime, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRun.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRun.kt index 51155e243a4..868845dcbf3 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRun.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRun.kt @@ -17,7 +17,7 @@ import java.io.File import java.io.IOException internal class TestExecutable( - val executableFile: File, + val executable: Executable, val loggedCompilationToolCall: LoggedData.CompilerCall, val testNames: Collection ) { @@ -42,7 +42,7 @@ internal class TestExecutable( } return TestExecutable( - executableFile = compilationResult.resultingArtifact.executableFile, + executable = compilationResult.resultingArtifact, loggedCompilationToolCall = compilationResult.loggedData, testNames = testNames ) diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunChecks.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunChecks.kt index 478bfa78af4..fac2cd09a3c 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunChecks.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunChecks.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.konan.test.blackbox.support.runner import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck.* +import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Settings import org.jetbrains.kotlin.utils.yieldIfNotNull import java.io.File import kotlin.time.Duration @@ -24,13 +25,16 @@ internal sealed interface TestRunCheck { class OutputDataFile(val file: File) : TestRunCheck class OutputMatcher(val match: (String) -> Boolean): TestRunCheck + + class FileCheckMatcher(val settings: Settings, val testDataFile: File): TestRunCheck } -internal class TestRunChecks( +internal data class TestRunChecks( val executionTimeoutCheck: ExecutionTimeout, private val exitCodeCheck: ExitCode, val outputDataFile: OutputDataFile?, - val outputMatcher: OutputMatcher? + val outputMatcher: OutputMatcher?, + val fileCheckMatcher: FileCheckMatcher?, ) : Iterable { override fun iterator() = iterator { @@ -38,6 +42,7 @@ internal class TestRunChecks( yield(exitCodeCheck) yieldIfNotNull(outputDataFile) yieldIfNotNull(outputMatcher) + yieldIfNotNull(fileCheckMatcher) } companion object { @@ -47,7 +52,8 @@ internal class TestRunChecks( executionTimeoutCheck = ExecutionTimeout.ShouldNotExceed(timeout), exitCodeCheck = ExitCode.Expected(0), outputDataFile = null, - outputMatcher = null + outputMatcher = null, + fileCheckMatcher = null, ) } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunners.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunners.kt index 59b12e8b0d4..9e8c72628fa 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunners.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/runner/TestRunners.kt @@ -23,9 +23,7 @@ internal object TestRunners { if (testTarget == hostTarget) { LocalTestRunner(testRun) } else { - val nativeHome = get() - val distribution = Distribution(nativeHome.dir.path) - val configurables = PlatformManager(distribution, true).platform(testTarget).configurables + val configurables = configurables val executor = cached( when { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/settings/SettingsContainers.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/settings/SettingsContainers.kt index f42c68e6c5c..1b3c0cd7ad3 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/settings/SettingsContainers.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/settings/SettingsContainers.kt @@ -5,6 +5,10 @@ package org.jetbrains.kotlin.konan.test.blackbox.support.settings +import org.jetbrains.kotlin.konan.target.Configurables +import org.jetbrains.kotlin.konan.target.Distribution +import org.jetbrains.kotlin.konan.target.HostManager +import org.jetbrains.kotlin.konan.target.PlatformManager import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue import org.jetbrains.kotlin.test.services.JUnit5Assertions.fail import kotlin.reflect.KClass @@ -59,3 +63,13 @@ internal class TestRunSettings(parent: TestClassSettings, settings: Iterable) : Settings(parent, settings) internal class SimpleTestRunSettings(parent: SimpleTestClassSettings, settings: Iterable) : Settings(parent, settings) + +internal val Settings.configurables: Configurables + get() { + val distribution = Distribution( + get().dir.path, + // Development variant of LLVM is used to have utilities like FileCheck + propertyOverrides = mapOf("llvmHome.${HostManager.hostName}" to "\$llvm.${HostManager.hostName}.dev") + ) + return PlatformManager(distribution, true).platform(get().testTarget).configurables + } diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java index f91f0f27388..3c7263a4d9b 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java @@ -13880,6 +13880,42 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT") diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java index 2232da06178..3427709752d 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java @@ -13880,6 +13880,42 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck") + @TestDataPath("$PROJECT_ROOT") + public class FileCheck { + @Test + public void testAllFilesPresentInFileCheck() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/kt53261") + @TestDataPath("$PROJECT_ROOT") + public class Kt53261 { + @Test + public void testAllFilesPresentInKt53261() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/kt53261"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing") + @TestDataPath("$PROJECT_ROOT") + public class StringConcatenationTypeNarrowing { + @Test + public void testAllFilesPresentInStringConcatenationTypeNarrowing() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @Test + @TestMetadata("kt53119_side_effect.kt") + public void testKt53119_side_effect() throws Exception { + runTest("compiler/testData/codegen/box/fileCheck/stringConcatenationTypeNarrowing/kt53119_side_effect.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/finally") @TestDataPath("$PROJECT_ROOT")