[K/N] Add trivial test for RemoveRedundantSafepoints phase

This commit is contained in:
Sergey Bogolepov
2022-03-28 13:49:29 +03:00
committed by Space
parent f90a56c131
commit f635e450df
3 changed files with 54 additions and 0 deletions
@@ -0,0 +1,42 @@
/*
* 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.Retain
class C
fun f(): Any {
return C()
}
fun g() = f()
// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#h(kotlin.Boolean){}kotlin.Any"
@Retain
fun h(cond: Boolean): Any {
// CHECK: Kotlin_mm_safePointFunctionPrologue
// CHECK-NOT: Kotlin_mm_safePointFunctionPrologue
// CHECK: br
if (cond) {
// CHECK: Kotlin_mm_safePointFunctionPrologue
// CHECK-NOT: Kotlin_mm_safePointFunctionPrologue
// CHECK: br
return listOf(C(), C())
} else {
// CHECK: Kotlin_mm_safePointFunctionPrologue
// CHECK-NOT: Kotlin_mm_safePointFunctionPrologue
return listOf(C(), C(), C())
}
// CHECK: }
}
// CHECK-LABEL: define void @"kfun:#main(){}"()
@Retain
fun main() {
// CHECK: Kotlin_mm_safePointFunctionPrologue
// CHECK-NOT: Kotlin_mm_safePointFunctionPrologue
println(g())
println(h(true))
// CHECK: }
}