Skip to content

Commit b9df9a7

Browse files
authored
Merge pull request #72415 from eeckstein/fix-eager-specializer
EagerSpecializer: fix a SIL verifier crash
2 parents abc1c4a + a5320a6 commit b9df9a7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/SILOptimizer/Transforms/EagerSpecializer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ static bool isTrivialReturnBlock(SILBasicBlock *RetBB) {
7272
// % = tuple ()
7373
// return % : $()
7474
if (RetOperand->getType().isVoid()) {
75+
if (!RetBB->args_empty())
76+
return false;
77+
7578
auto *TupleI = dyn_cast<TupleInst>(RetBB->begin());
7679
if (!TupleI || !TupleI->getType().isVoid())
7780
return false;

test/SILOptimizer/eager_specialize.sil

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,23 @@ bb(%0: $*T):
864864
return %t : $()
865865
}
866866

867+
// CHECK-LABEL: sil [ossa] @testReturnBlockWithArgument
868+
// CHECK: [[BB1:bb[0-9]+]](%{{.*}} : $Optional<()>):
869+
// CHECK-NEXT: br [[BBRET:bb[0-9]+]]
870+
// CHECK: [[BBRET]]:
871+
// CHECK-NEXT: tuple ()
872+
// CHECK-NEXT: return
873+
// CHECK: } // end sil function 'testReturnBlockWithArgument'
874+
sil [_specialize exported: false, kind: full, where T == S] [ossa] @testReturnBlockWithArgument : $@convention(thin) <T> (@thick T.Type) -> () {
875+
bb0(%0 : $@thick T.Type):
876+
%41 = enum $Optional<()>, #Optional.none!enumelt
877+
br bb4(%41 : $Optional<()>)
878+
879+
bb4(%37 : $Optional<()>):
880+
%38 = tuple ()
881+
return %38 : $()
882+
}
883+
867884
sil_vtable ClassUsingThrowingP {
868885
#ClassUsingThrowingP.init!allocator: (ClassUsingThrowingP.Type) -> () -> ClassUsingThrowingP : @$s34eager_specialize_throwing_function19ClassUsingThrowingPCACycfC // ClassUsingThrowingP.__allocating_init()
869886
#ClassUsingThrowingP.init!initializer: (ClassUsingThrowingP.Type) -> () -> ClassUsingThrowingP : @$s34eager_specialize_throwing_function19ClassUsingThrowingPCACycfc // ClassUsingThrowingP.init()

0 commit comments

Comments
 (0)