[K/N] Fix filecheck_enum_when for -opt build.

This commit is contained in:
Sergey Bogolepov
2022-04-28 14:15:31 +04:00
committed by Space
parent 08ba89b4ec
commit ba9c2e51a7
2 changed files with 9 additions and 0 deletions
@@ -6006,6 +6006,10 @@ fileCheckTest("filecheck_escape_analysis_enabled") {
} }
fileCheckTest("filecheck_enum_when") { 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') annotatedSource = project.file('filecheck/enum_when.kt')
} }
@@ -13,13 +13,18 @@ enum class COLOR {
fun main() { fun main() {
for (i in COLOR.values()) { for (i in COLOR.values()) {
// CHECK: = call i32 @"kfun:kotlin.Enum#<get-ordinal>(){}kotlin.Int"( // CHECK: = call i32 @"kfun:kotlin.Enum#<get-ordinal>(){}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) { print(when (i) {
// we can't check the register is same, because it can be saved on stack and loaded back // 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: icmp eq i32 %{{[0-9a-z]*}}, 0
// CHECK-OPT: icmp eq i32 %{{[0-9a-z]*}}, 0
COLOR.RED -> 0xff0000 COLOR.RED -> 0xff0000
// CHECK: icmp eq i32 %{{[0-9a-z]*}}, 1 // CHECK: icmp eq i32 %{{[0-9a-z]*}}, 1
// CHECK-OPT: icmp eq i32 %{{[0-9a-z]*}}, 1
COLOR.GREEN -> 0x00ff00 COLOR.GREEN -> 0x00ff00
// CHECK: icmp eq i32 %{{[0-9a-z]*}}, 2 // CHECK: icmp eq i32 %{{[0-9a-z]*}}, 2
// CHECK-OPT: icmp eq i32 %{{[0-9a-z]*}}, 2
COLOR.BLUE -> 0x0000ff COLOR.BLUE -> 0x0000ff
}) })
} }