Skip to content

Commit cd0d8d1

Browse files
authored
Merge pull request #77992 from meg-gupta/delassert
Remove incorrect assert in ConditionForwarding
2 parents aeb475b + 2349859 commit cd0d8d1

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

lib/SILOptimizer/Transforms/ConditionForwarding.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ bool ConditionForwarding::tryOptimize(SwitchEnumInst *SEI) {
297297
if (HasEnumArg) {
298298
// The successor block has a new argument (which we created above) where
299299
// we have to pass the Enum.
300-
assert(!getFunction()->hasOwnership() ||
301-
EI->getType().isTrivial(*getFunction()));
302300
BranchArgs.push_back(EI);
303301
}
304302
B.createBranch(BI->getLoc(), SEDest, BranchArgs);

test/SILOptimizer/conditionforwarding_nontrivial_ossa.sil

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,34 @@ bb6:
363363
return %r : $()
364364
}
365365

366+
// CHECK-LABEL: sil [ossa] @nontrivialenumarg :
367+
// CHECK-NOT: switch_enum
368+
// CHECK-LABEL: } // end sil function 'nontrivialenumarg'
369+
sil [ossa] @nontrivialenumarg : $@convention(thin) (@guaranteed Klass) -> @owned Optional<Klass> {
370+
bb0(%0 : @guaranteed $Klass):
371+
cond_br undef, bb1, bb2
372+
373+
bb1:
374+
%2 = enum $Optional<Klass>, #Optional.some!enumelt, %0
375+
br bb3(%2)
376+
377+
bb2:
378+
%3 = enum $Optional<Klass>, #Optional.some!enumelt, %0
379+
br bb3(%3)
380+
381+
bb3(%7 : @guaranteed $Optional<Klass>):
382+
switch_enum %7, case #Optional.some!enumelt: bb4, case #Optional.none!enumelt: bb5
383+
384+
bb4(%9 : @guaranteed $Klass):
385+
apply undef(%7) : $@convention(thin) (@guaranteed Optional<Klass>) -> ()
386+
%10 = enum $Optional<Klass>, #Optional.some!enumelt, %9
387+
br bb6(%10)
388+
389+
bb5:
390+
%12 = enum $Optional<Klass>, #Optional.none!enumelt
391+
br bb6(%12)
392+
393+
bb6(%14 : @guaranteed $Optional<Klass>):
394+
%15 = copy_value %14
395+
return %15
396+
}

0 commit comments

Comments
 (0)