Skip to content

Commit e81c2b8

Browse files
authored
Merge pull request #14648 from gottesmm/pr-6af503b7a70e6705bcce4becd3ed620695f56c51
2 parents c110f0b + 398f20c commit e81c2b8

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

lib/SILGen/SILGenBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,14 @@ ManagedValue SILGenBuilder::createBridgeObjectToRef(SILLocation loc,
762762
return cloner.clone(result);
763763
}
764764

765+
ManagedValue SILGenBuilder::createRefToBridgeObject(SILLocation loc,
766+
ManagedValue mv,
767+
SILValue bits) {
768+
CleanupCloner cloner(*this, mv);
769+
SILValue result = createRefToBridgeObject(loc, mv.forward(SGF), bits);
770+
return cloner.clone(result);
771+
}
772+
765773
ManagedValue SILGenBuilder::createBlockToAnyObject(SILLocation loc,
766774
ManagedValue v,
767775
SILType destType) {

lib/SILGen/SILGenBuilder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ class SILGenBuilder : public SILBuilder {
360360
ManagedValue createBridgeObjectToRef(SILLocation loc, ManagedValue mv,
361361
SILType destType);
362362

363+
using SILBuilder::createRefToBridgeObject;
364+
ManagedValue createRefToBridgeObject(SILLocation loc, ManagedValue mv,
365+
SILValue bits);
366+
363367
using SILBuilder::createBranch;
364368
BranchInst *createBranch(SILLocation Loc, SILBasicBlock *TargetBlock,
365369
ArrayRef<ManagedValue> Args);

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,8 @@ static ManagedValue emitBuiltinCastToBridgeObject(SILGenFunction &SGF,
677677
SILValue undef = SILUndef::get(objPointerType, SGF.SGM.M);
678678
return ManagedValue::forUnmanaged(undef);
679679
}
680-
681-
// Save the cleanup on the argument so we can forward it onto the cast
682-
// result.
683-
auto refCleanup = args[0].getCleanup();
684-
SILValue ref = args[0].getValue();
680+
681+
ManagedValue ref = args[0];
685682
SILValue bits = args[1].getUnmanagedValue();
686683

687684
// If the argument is existential, open it.
@@ -691,9 +688,8 @@ static ManagedValue emitBuiltinCastToBridgeObject(SILGenFunction &SGF,
691688
SILType loweredOpenedTy = SGF.getLoweredLoadableType(openedTy);
692689
ref = SGF.B.createOpenExistentialRef(loc, ref, loweredOpenedTy);
693690
}
694-
695-
SILValue result = SGF.B.createRefToBridgeObject(loc, ref, bits);
696-
return ManagedValue(result, refCleanup);
691+
692+
return SGF.B.createRefToBridgeObject(loc, ref, bits);
697693
}
698694

699695
/// Specialized emitter for Builtin.castReferenceFromBridgeObject.

0 commit comments

Comments
 (0)