@@ -419,11 +419,6 @@ struct AddressLoweringState {
419
419
// parameters are rewritten.
420
420
SmallBlotSetVector<FullApplySite, 16 > indirectApplies;
421
421
422
- // checked_cast_br instructions with loadable source type and opaque target
423
- // type need to be rewritten in a post-pass, once all the uses of the opaque
424
- // target value are rewritten to their address forms.
425
- SmallVector<CheckedCastBranchInst *, 8 > opaqueResultCCBs;
426
-
427
422
// All function-exiting terminators (return or throw instructions).
428
423
SmallVector<TermInst *, 8 > exitingInsts;
429
424
@@ -611,15 +606,6 @@ void OpaqueValueVisitor::mapValueStorage() {
611
606
if (auto apply = FullApplySite::isa (&inst))
612
607
checkForIndirectApply (apply);
613
608
614
- // Collect all checked_cast_br instructions that have a loadable source
615
- // type and opaque target type
616
- if (auto *ccb = dyn_cast<CheckedCastBranchInst>(&inst)) {
617
- if (!ccb->getSourceLoweredType ().isAddressOnly (*ccb->getFunction ()) &&
618
- ccb->getTargetLoweredType ().isAddressOnly (*ccb->getFunction ())) {
619
- pass.opaqueResultCCBs .push_back (ccb);
620
- }
621
- }
622
-
623
609
for (auto result : inst.getResults ()) {
624
610
if (isPseudoCallResult (result) || isPseudoReturnValue (result))
625
611
continue ;
@@ -3177,6 +3163,10 @@ class DefRewriter : SILInstructionVisitor<DefRewriter> {
3177
3163
CallArgRewriter (tai, pass).rewriteArguments ();
3178
3164
ApplyRewriter (tai, pass).convertApplyWithIndirectResults ();
3179
3165
return ;
3166
+ } else if (auto *ccbi = dyn_cast_or_null<CheckedCastBranchInst>(
3167
+ arg->getTerminatorForResult ())) {
3168
+ CheckedCastBrRewriter (ccbi, pass).rewrite ();
3169
+ return ;
3180
3170
}
3181
3171
LLVM_DEBUG (llvm::dbgs () << " REWRITE ARG " ; arg->dump ());
3182
3172
if (storage.storageAddress )
@@ -3412,12 +3402,6 @@ static void rewriteFunction(AddressLoweringState &pass) {
3412
3402
}
3413
3403
}
3414
3404
3415
- // Rewrite all checked_cast_br instructions with loadable source type and
3416
- // opaque target type now
3417
- for (auto *ccb : pass.opaqueResultCCBs ) {
3418
- CheckedCastBrRewriter (ccb, pass).rewrite ();
3419
- }
3420
-
3421
3405
// Rewrite this function's return value now that all opaque values within the
3422
3406
// function are rewritten. This still depends on a valid ValueStorage
3423
3407
// projection operands.
0 commit comments