[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
@@ -5931,6 +5931,7 @@ Task fileCheckTest(String name, Closure<FileCheckTest> configureClosure) {
if (!isCrossCompiling) {
extraOpts project.globalTestArgs
}
extraOpts task.extraOpts
extraOpts "-Xtemporary-files-dir=$testOutputFileCheck/$name/$target"
extraOpts "-Xsave-llvm-ir-after=${task.phaseToCheck}"
if (lib != null) {
@@ -5975,6 +5976,14 @@ if (HostManager.@Companion.hostIsMac) {
// LLVM might infer attributes.
phaseToCheck = "BitcodeOptimization"
}
fileCheckTest("filecheck_redundant_safepoints_removal") {
enabled = isExperimentalMM && project.globalTestArgs.contains("-opt")
annotatedSource = project.file('filecheck/redundant_safepoints.kt')
targetName = "watchos_arm32"
extraOpts = ["-Xbinary=memoryModel=experimental", "-opt"]
phaseToCheck = "RemoveRedundantSafepoints"
}
}
fileCheckTest("filecheck_replace_invoke_with_call") {
@@ -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: }
}
@@ -69,6 +69,9 @@ open class FileCheckTest : DefaultTask() {
@get:Optional
var additionalFileCheckFlags: List<String>? = null
@get:Input
var extraOpts: List<String> = emptyList()
@get:Optional
@get:Input
var targetName: String = project.testTarget.name