Skip to content

Commit e989c9b

Browse files
committed
SpeculativeDevirtualizer - Fix OSSA support
The OSSA verifier was never enabled for block terminators. So we could blindly give terminator results any ownership without knowing.
1 parent 79565a4 commit e989c9b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/SILOptimizer/Transforms/SpeculativeDevirtualizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,21 @@ static FullApplySite speculateMonomorphicTarget(FullApplySite AI,
146146
SILFunction *F = AI.getFunction();
147147
SILBasicBlock *Entry = AI.getParent();
148148

149+
ClassMethodInst *CMI = cast<ClassMethodInst>(AI.getCallee());
150+
149151
// Iden is the basic block containing the direct call.
150152
SILBasicBlock *Iden = F->createBasicBlock();
151153
// Virt is the block containing the slow virtual call.
152154
SILBasicBlock *Virt = F->createBasicBlock();
153155
Iden->createPhiArgument(SILType::getPrimitiveObjectType(SubType),
154-
OwnershipKind::Owned);
156+
CMI->getOperand()->getOwnershipKind());
155157

156158
SILBasicBlock *Continue = Entry->split(It);
157159

158160
SILBuilderWithScope Builder(Entry, AI.getInstruction());
159161
// Create the checked_cast_branch instruction that checks at runtime if the
160162
// class instance is identical to the SILType.
161163

162-
ClassMethodInst *CMI = cast<ClassMethodInst>(AI.getCallee());
163-
164164
CCBI = Builder.createCheckedCastBranch(AI.getLoc(), /*exact*/ true,
165165
CMI->getOperand(),
166166
SILType::getPrimitiveObjectType(SubType),

0 commit comments

Comments
 (0)