File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1535,6 +1535,14 @@ class SourceFileScope {
1535
1535
sgm.getASTContext ().getIdentifier (" errorInMain" ),
1536
1536
sgm.Types .getEmptyTupleType (), {}, {error});
1537
1537
1538
+ // Then end the lifetime of the error.
1539
+ //
1540
+ // We do this to appease the ownership verifier. We do not care about
1541
+ // actually destroying the value since we are going to immediately exit,
1542
+ // so this saves us a slight bit of code-size since end_lifetime is
1543
+ // stripped out after ownership is removed.
1544
+ SGF.B .createEndLifetime (moduleLoc, error);
1545
+
1538
1546
// Signal an abnormal exit by returning 1.
1539
1547
SGF.Cleanups .emitCleanupsForReturn (CleanupLocation::get (moduleLoc),
1540
1548
IsForUnwind);
Original file line number Diff line number Diff line change 1
- // RUN: %target-swift-emit-silgen %s | %FileCheck %s
1
+ // RUN: %target-swift-emit-silgen -enable-sil-ownership %s | %FileCheck %s
2
2
3
3
enum MyError : Error {
4
4
case A, B
@@ -21,6 +21,7 @@ throw MyError.A
21
21
22
22
// CHECK: bb2([[T0:%.*]] : @owned $Error):
23
23
// CHECK: builtin "errorInMain"([[T0]] : $Error)
24
+ // CHECK: end_lifetime [[T0]]
24
25
// CHECK: [[T0:%.*]] = integer_literal $Builtin.Int32, 1
25
26
// CHECK: [[T1:%.*]] = struct $Int32 ([[T0]] : $Builtin.Int32)
26
27
// CHECK: br bb1([[T1]] : $Int32)
You can’t perform that action at this time.
0 commit comments