Skip to content

Commit 70031d3

Browse files
jckarterkitaisreal
authored andcommitted
SILGen: Don't inject "willThrow" hooks before rethrow propagation branches.
The hook is intended to be used by debuggers to catch the point a `throw` happened in user source. It's unnecessary and undesirable to hook in places where an already-thrown error is just being implicitly propagated.
1 parent be1d896 commit 70031d3

File tree

4 files changed

+0
-14
lines changed

4 files changed

+0
-14
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4609,9 +4609,6 @@ SILValue SILGenFunction::emitApplyWithRethrow(SILLocation loc, SILValue fn,
46094609
SILValue error = errorBB->createPhiArgument(fnConv.getSILErrorType(),
46104610
ValueOwnershipKind::Owned);
46114611

4612-
B.createBuiltin(loc, SGM.getASTContext().getIdentifier("willThrow"),
4613-
SGM.Types.getEmptyTupleType(), {}, {error});
4614-
46154612
Cleanups.emitCleanupsForReturn(CleanupLocation::get(loc), IsForUnwind);
46164613
B.createThrow(loc, error);
46174614
}

lib/SILOptimizer/IPO/EagerSpecializer.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ emitApplyWithRethrow(SILBuilder &Builder,
172172
SILValue Error = ErrorBB->createPhiArgument(fnConv.getSILErrorType(),
173173
ValueOwnershipKind::Owned);
174174

175-
Builder.createBuiltin(Loc,
176-
Builder.getASTContext().getIdentifier("willThrow"),
177-
Builder.getModule().Types.getEmptyTupleType(),
178-
SubstitutionMap(),
179-
{Error});
180-
181175
EmitCleanup(Builder, Loc);
182176
addThrowValue(ErrorBB, Error);
183177
}

test/SILGen/errors.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class HasThrowingInit {
269269
// CHECK: bb1([[SELF:%.*]] : @owned $HasThrowingInit):
270270
// CHECK-NEXT: return [[SELF]]
271271
// CHECK: bb2([[ERROR:%.*]] : @owned $Error):
272-
// CHECK-NEXT: builtin "willThrow"
273272
// CHECK-NEXT: throw [[ERROR]]
274273

275274
// CHECK-LABEL: sil hidden [ossa] @$s6errors15HasThrowingInit{{.*}} : $@convention(method) (Int, @owned HasThrowingInit) -> (@owned HasThrowingInit, @error Error) {
@@ -320,7 +319,6 @@ protocol Doomed {
320319
// CHECK: [[T0:%.*]] = tuple ()
321320
// CHECK: return [[T0]] : $()
322321
// CHECK: bb2([[T0:%.*]] : @owned $Error):
323-
// CHECK: builtin "willThrow"([[T0]] : $Error)
324322
// CHECK: throw [[T0]] : $Error
325323
struct DoomedStruct : Doomed {
326324
func check() throws {}
@@ -335,7 +333,6 @@ struct DoomedStruct : Doomed {
335333
// CHECK: end_borrow [[BORROWED_SELF]]
336334
// CHECK: return [[T0]] : $()
337335
// CHECK: bb2([[T0:%.*]] : @owned $Error):
338-
// CHECK: builtin "willThrow"([[T0]] : $Error)
339336
// CHECK: end_borrow [[BORROWED_SELF]]
340337
// CHECK: throw [[T0]] : $Error
341338
class DoomedClass : Doomed {
@@ -376,7 +373,6 @@ func testThunk(_ fn: () throws -> Int) throws -> Int {
376373
// CHECK: [[T0:%.*]] = tuple ()
377374
// CHECK: return [[T0]]
378375
// CHECK: bb2([[T0:%.*]] : @owned $Error):
379-
// CHECK: builtin "willThrow"([[T0]] : $Error)
380376
// CHECK: throw [[T0]] : $Error
381377

382378
func createInt(_ fn: () -> Int) throws {}

test/SILOptimizer/eager_specialize.sil

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ bb2:
228228
// CHECK: try_apply %{{.*}}(%{{.*}}, %{{.*}}) : $@convention(thin) (Int, Int) -> (Int, @error Error), normal bb8, error bb7
229229

230230
// CHECK: bb7(%{{.*}} : $Error):
231-
// CHECK: %{{.*}} = builtin "willThrow"(%{{.*}} : $Error) : $()
232231
// CHECK: br bb3(%{{.*}} : $Error)
233232

234233
// CHECK: bb8(%{{.*}} : $Int):

0 commit comments

Comments
 (0)