|
| 1 | +// RUN: %target-swift-emit-ir -enable-experimental-feature Embedded -wmo -Xllvm -link-embedded-runtime=0 %s -O | %FileCheck %s --check-prefix=CHECK-NOMESSAGE |
| 2 | +// RUN: %target-swift-emit-ir -enable-experimental-feature Embedded -wmo -Xllvm -link-embedded-runtime=0 %s -Osize | %FileCheck %s --check-prefix=CHECK-NOMESSAGE |
| 3 | +// RUN: %target-swift-emit-ir -enable-experimental-feature Embedded -wmo -Xllvm -link-embedded-runtime=0 %s -O -assert-config Debug | %FileCheck %s --check-prefix=CHECK-MESSAGE |
| 4 | +// RUN: %target-swift-emit-ir -enable-experimental-feature Embedded -wmo -Xllvm -link-embedded-runtime=0 %s -Osize -assert-config Debug | %FileCheck %s --check-prefix=CHECK-MESSAGE |
| 5 | + |
| 6 | +// REQUIRES: swift_in_compiler |
| 7 | +// REQUIRES: optimized_stdlib |
| 8 | +// REQUIRES: OS=macosx || OS=linux-gnu |
| 9 | + |
| 10 | +@_extern(c) |
| 11 | +public func external() |
| 12 | + |
| 13 | +public func test(i: Int) { |
| 14 | + precondition(i % 2 == 0, "precondition 1") |
| 15 | + external() |
| 16 | + precondition(i % 3 == 0, "precondition 3") |
| 17 | + external() |
| 18 | + precondition(i % 5 == 0, "precondition 5") |
| 19 | + external() |
| 20 | + precondition(i % 7 == 0, "precondition 7") |
| 21 | +} |
| 22 | + |
| 23 | +// "Non-production builds" - We expect 4 separate _assertionFailure() calls with different values |
| 24 | +// CHECK-MESSAGE: define {{.*}}void @"$s4main4test1iySi_tF"(i64 %0) {{.*}}{ |
| 25 | +// CHECK-MESSAGE: call {{.*}}@"$ss17_assertionFailure |
| 26 | +// CHECK-MESSAGE: unreachable |
| 27 | +// CHECK-MESSAGE: call {{.*}}@"$ss17_assertionFailure |
| 28 | +// CHECK-MESSAGE: unreachable |
| 29 | +// CHECK-MESSAGE: call {{.*}}@"$ss17_assertionFailure |
| 30 | +// CHECK-MESSAGE: unreachable |
| 31 | +// CHECK-MESSAGE: call {{.*}}@"$ss17_assertionFailure |
| 32 | +// CHECK-MESSAGE: unreachable |
| 33 | +// CHECK-MESSAGE: } |
| 34 | + |
| 35 | +// "Production builds" - We expect 4 separate trap blocks in the IR. |
| 36 | +// CHECK-NOMESSAGE: define {{.*}}void @"$s4main4test1iySi_tF"(i64 %0) {{.*}}{ |
| 37 | +// CHECK-NOMESSAGE: tail call void asm sideeffect "", "n"(i32 0) #3 |
| 38 | +// CHECK-NOMESSAGE: tail call void @llvm.trap() |
| 39 | +// CHECK-NOMESSAGE: unreachable |
| 40 | +// CHECK-NOMESSAGE: tail call void asm sideeffect "", "n"(i32 1) #3 |
| 41 | +// CHECK-NOMESSAGE: tail call void @llvm.trap() |
| 42 | +// CHECK-NOMESSAGE: unreachable |
| 43 | +// CHECK-NOMESSAGE: tail call void asm sideeffect "", "n"(i32 2) #3 |
| 44 | +// CHECK-NOMESSAGE: tail call void @llvm.trap() |
| 45 | +// CHECK-NOMESSAGE: unreachable |
| 46 | +// CHECK-NOMESSAGE: tail call void asm sideeffect "", "n"(i32 3) #3 |
| 47 | +// CHECK-NOMESSAGE: tail call void @llvm.trap() |
| 48 | +// CHECK-NOMESSAGE: unreachable |
| 49 | +// CHECK-NOMESSAGE: } |
0 commit comments