|
1 | 1 | // RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s
|
2 | 2 | // RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=CAPTURE
|
| 3 | +// RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=OPT |
3 | 4 |
|
4 | 5 | // REQUIRES: CPU=x86_64
|
5 | 6 |
|
| 7 | +// CHECK-DAG: [[FILENAME:@[0-9]+]] = {{.*}} c"{{.*}}closure.swift\00" |
| 8 | +// OPT: [[FILENAME:@[0-9]+]] = {{.*}} [1 x i8] zeroinitializer |
| 9 | + |
6 | 10 | // -- partial_apply context metadata
|
7 | 11 |
|
8 |
| -// CHECK: [[METADATA:@.*]] = private constant %swift.full_boxmetadata { void (%swift.refcounted*)* @objectdestroy, i8** null, %swift.type { i64 1024 }, i32 16, i8* bitcast ({ i32, i32, i32, i32 }* @"\01l__swift5_reflection_descriptor" to i8*) } |
| 12 | +// CHECK-DAG: [[METADATA:@.*]] = private constant %swift.full_boxmetadata { void (%swift.refcounted*)* @objectdestroy, i8** null, %swift.type { i64 1024 }, i32 16, i8* bitcast ({ i32, i32, i32, i32 }* @"\01l__swift5_reflection_descriptor" to i8*) } |
9 | 13 |
|
10 | 14 | func a(i i: Int) -> (Int) -> Int {
|
11 | 15 | return { x in i }
|
@@ -65,3 +69,11 @@ func useClosure(_ cl : () -> ()) {}
|
65 | 69 | func no_capture_descriptor(_ c: C, _ d: C, _ e: C, _ f: C, _ g: C) {
|
66 | 70 | useClosure( { _ = c ; _ = d ; _ = e ; _ = f ; _ = g })
|
67 | 71 | }
|
| 72 | + |
| 73 | +// CHECK-LABEL: define hidden swiftcc { i8*, %swift.refcounted* } @"$s7closure9letEscape1fyycyyXE_tF"(i8*, %swift.opaque*) |
| 74 | +// CHECK: call i1 @swift_isEscapingClosureAtFileLocation(%swift.refcounted* {{.*}}, i8* getelementptr inbounds ({{.*}} [[FILENAME]] |
| 75 | +// OPT-LABEL: define hidden swiftcc { i8*, %swift.refcounted* } @"$s7closure9letEscape1fyycyyXE_tF"(i8*, %swift.opaque*) |
| 76 | +// OPT: call i1 @swift_isEscapingClosureAtFileLocation(%swift.refcounted* {{.*}}, i8* getelementptr inbounds ({{.*}} [[FILENAME]] |
| 77 | +func letEscape(f: () -> ()) -> () -> () { |
| 78 | + return withoutActuallyEscaping(f) { return $0 } |
| 79 | +} |
0 commit comments