Skip to content

Commit 8353a8c

Browse files
authored
Merge pull request #78064 from meg-gupta/fixcfassert6.1
[6.1] Remove incorrect assert in ConditionForwarding
2 parents 670a5f1 + a3120d8 commit 8353a8c

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,36 @@ 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 : $Klass
375+
br bb3(%2 : $Optional<Klass>)
376+
377+
bb2:
378+
%4 = enum $Optional<Klass>, #Optional.some!enumelt, %0 : $Klass
379+
br bb3(%4 : $Optional<Klass>)
380+
381+
bb3(%6 : @guaranteed $Optional<Klass>):
382+
%7 = borrowed %6 : $Optional<Klass> from (%0 : $Klass)
383+
switch_enum %7 : $Optional<Klass>, case #Optional.some!enumelt: bb4, case #Optional.none!enumelt: bb5
384+
385+
bb4(%9 : @guaranteed $Klass):
386+
%10 = apply undef(%7) : $@convention(thin) (@guaranteed Optional<Klass>) -> ()
387+
%11 = enum $Optional<Klass>, #Optional.some!enumelt, %9 : $Klass
388+
br bb6(%11 : $Optional<Klass>)
389+
390+
bb5:
391+
%13 = enum $Optional<Klass>, #Optional.none!enumelt
392+
br bb6(%13 : $Optional<Klass>)
393+
394+
bb6(%15 : @guaranteed $Optional<Klass>):
395+
%16 = borrowed %15 : $Optional<Klass> from (%0 : $Klass)
396+
%17 = copy_value %16 : $Optional<Klass>
397+
return %17 : $Optional<Klass>
398+
}

0 commit comments

Comments
 (0)