Skip to content

Commit

Permalink
Merge pull request #72415 from eeckstein/fix-eager-specializer
Browse files Browse the repository at this point in the history
EagerSpecializer: fix a SIL verifier crash
  • Loading branch information
eeckstein committed Mar 19, 2024
2 parents abc1c4a + a5320a6 commit b9df9a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/SILOptimizer/Transforms/EagerSpecializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ static bool isTrivialReturnBlock(SILBasicBlock *RetBB) {
// % = tuple ()
// return % : $()
if (RetOperand->getType().isVoid()) {
if (!RetBB->args_empty())
return false;

auto *TupleI = dyn_cast<TupleInst>(RetBB->begin());
if (!TupleI || !TupleI->getType().isVoid())
return false;
Expand Down
17 changes: 17 additions & 0 deletions test/SILOptimizer/eager_specialize.sil
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,23 @@ bb(%0: $*T):
return %t : $()
}

// CHECK-LABEL: sil [ossa] @testReturnBlockWithArgument
// CHECK: [[BB1:bb[0-9]+]](%{{.*}} : $Optional<()>):
// CHECK-NEXT: br [[BBRET:bb[0-9]+]]
// CHECK: [[BBRET]]:
// CHECK-NEXT: tuple ()
// CHECK-NEXT: return
// CHECK: } // end sil function 'testReturnBlockWithArgument'
sil [_specialize exported: false, kind: full, where T == S] [ossa] @testReturnBlockWithArgument : $@convention(thin) <T> (@thick T.Type) -> () {
bb0(%0 : $@thick T.Type):
%41 = enum $Optional<()>, #Optional.none!enumelt
br bb4(%41 : $Optional<()>)

bb4(%37 : $Optional<()>):
%38 = tuple ()
return %38 : $()
}

sil_vtable ClassUsingThrowingP {
#ClassUsingThrowingP.init!allocator: (ClassUsingThrowingP.Type) -> () -> ClassUsingThrowingP : @$s34eager_specialize_throwing_function19ClassUsingThrowingPCACycfC // ClassUsingThrowingP.__allocating_init()
#ClassUsingThrowingP.init!initializer: (ClassUsingThrowingP.Type) -> () -> ClassUsingThrowingP : @$s34eager_specialize_throwing_function19ClassUsingThrowingPCACycfc // ClassUsingThrowingP.init()
Expand Down

0 comments on commit b9df9a7

Please sign in to comment.