mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fix a bug related to the opened archetypes tracking
If a SILBuilder creates a new instruction based on an old instruction and a new instruction is supposed to use some opened archetypes, one needs to set a proper opened archetypes context in the builder based on the opened archetypes used by the old instruction. This fixes rdar://28024272
This commit is contained in:
@@ -721,6 +721,7 @@ SILCombiner::createApplyWithConcreteType(FullApplySite AI,
|
||||
|
||||
FullApplySite NewAI;
|
||||
Builder.setCurrentDebugScope(AI.getDebugScope());
|
||||
Builder.addOpenedArchetypeOperands(AI.getInstruction());
|
||||
|
||||
if (auto *TAI = dyn_cast<TryApplyInst>(AI))
|
||||
NewAI = Builder.createTryApply(AI.getLoc(), AI.getCallee(),
|
||||
@@ -1156,6 +1157,7 @@ SILInstruction *SILCombiner::visitApplyInst(ApplyInst *AI) {
|
||||
// The type of the substitution is the source type of the thin to thick
|
||||
// instruction.
|
||||
SILType substTy = TTTFI->getOperand()->getType();
|
||||
Builder.addOpenedArchetypeOperands(AI);
|
||||
auto *NewAI = Builder.createApply(AI->getLoc(), TTTFI->getOperand(),
|
||||
substTy, AI->getType(),
|
||||
AI->getSubstitutions(), Arguments,
|
||||
|
||||
@@ -50,6 +50,7 @@ STATISTIC(NumTargetsPredicted, "Number of monomorphic functions predicted");
|
||||
static FullApplySite CloneApply(FullApplySite AI, SILBuilder &Builder) {
|
||||
// Clone the Apply.
|
||||
Builder.setCurrentDebugScope(AI.getDebugScope());
|
||||
Builder.addOpenedArchetypeOperands(AI.getInstruction());
|
||||
auto Args = AI.getArguments();
|
||||
SmallVector<SILValue, 8> Ret(Args.size());
|
||||
for (unsigned i = 0, e = Args.size(); i != e; ++i)
|
||||
|
||||
Reference in New Issue
Block a user