Always inline primitive unbox functions in IR level

Merge-request: KT-MR-6708
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
Vladimir Sukharev
2022-08-09 18:07:02 +00:00
committed by Space
parent d0fb997967
commit c84a70c654
14 changed files with 260 additions and 0 deletions
@@ -0,0 +1,34 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK-NOT: {{call|invoke}} i64 @"kfun:kotlin#<Long-unbox>
// CHECK-NOT: {{call|invoke}} i64 @"kfun:kotlin#<ULong-unbox>
// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin#<Int-unbox>
// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin#<UInt-unbox>
// CHECK-NOT: {{call|invoke}} signext i16 @"kfun:kotlin#<Short-unbox>
// CHECK-NOT: {{call|invoke}} zeroext i16 @"kfun:kotlin#<UShort-unbox>
// CHECK-NOT: {{call|invoke}} signext i8 @"kfun:kotlin#<Byte-unbox>
// CHECK-NOT: {{call|invoke}} zeroext i8 @"kfun:kotlin#<UByte-unbox>
// CHECK-NOT: {{call|invoke}} zeroext i16 @"kfun:kotlin#<Char-unbox>
// CHECK-NOT: {{call|invoke}} zeroext i1 @"kfun:kotlin#<Boolean-unbox>
// CHECK-NOT: {{call|invoke}} double @"kfun:kotlin#<Double-unbox>
// CHECK-NOT: {{call|invoke}} float @"kfun:kotlin#<Float-unbox>
// CHECK-NOT: {{call|invoke}} i8* @"kfun:kotlin.native.internal#<NativePtr-unbox>
// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin.native.concurrent#<Future-unbox>
// CHECK-NOT: {{call|invoke}} i32 @"kfun:kotlin.native.concurrent#<Worker-unbox>
// CHECK-NOT: {{call|invoke}} <4 x float> @"kfun:kotlin.native#<Vector128-unbox>
// CHECK-NOT: {{call|invoke}} %struct.ObjHeader* @"kfun:kotlin#<Result-unbox>
// On ARM64, generated functions IntToNSNumber and UIntToNSNumber may contain non-converted invocations of unbox functions.
// CHECK-ARM64: IntToNSNumber
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} i8* @"kfun:kotlinx.cinterop#<CPointer-unbox>
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} i8* @"kfun:kotlinx.cinterop#<NativePointed-unbox>
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} i8* @"kfun:kotlin.native.internal#<NonNullNativePtr-unbox>
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} i8* @"kfun:kotlinx.cinterop#<StableRef-unbox>
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} %struct.ObjHeader* @"kfun:kotlin#<UByteArray-unbox>
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} %struct.ObjHeader* @"kfun:kotlin#<UIntArray-unbox>
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} %struct.ObjHeader* @"kfun:kotlin#<ULongArray-unbox>
@@ -0,0 +1,9 @@
/*
* 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 main(arr: Array<String>) {
println(arr[0].toInt() + 1)
}
// CHECK: {{call|invoke}} %struct.ObjHeader* @"kfun:kotlin#<UShortArray-unbox>
@@ -0,0 +1,17 @@
/*
* 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.
*/
value class C(val x: Any)
val c = C(42)
fun main() {
println(c.x)
}
// CHECK: {{call|invoke}} %struct.ObjHeader* @"kfun:#<C-unbox>
// Note: <C-unbox> is called from IR of generated methods like
// FUN BRIDGE_METHOD(target=FUN GENERATED_SINGLE_FIELD_VALUE_CLASS_MEMBER name:equals
// FUN BRIDGE_METHOD(target=FUN GENERATED_SINGLE_FIELD_VALUE_CLASS_MEMBER name:hashCode
// FUN BRIDGE_METHOD(target=FUN GENERATED_SINGLE_FIELD_VALUE_CLASS_MEMBER name:toString