Skip to content

Commit aff36b0

Browse files
committed
SIL: fix cloning of keypath instruction
Don't include type-dependent operands in the argument list of the new keypath instruction. Also enable the assert, which catches this problem, in release builds. Fixes a compiler crash.
1 parent 1b916b2 commit aff36b0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,8 +3625,8 @@ template <typename ImplClass>
36253625
void SILCloner<ImplClass>::visitKeyPathInst(KeyPathInst *Inst) {
36263626
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
36273627
SmallVector<SILValue, 4> opValues;
3628-
for (auto &op : Inst->getAllOperands())
3629-
opValues.push_back(getOpValue(op.get()));
3628+
for (Operand *op : Inst->getRealOperands())
3629+
opValues.push_back(getOpValue(op->get()));
36303630

36313631
recordClonedInstruction(Inst,
36323632
getBuilder().createKeyPath(

lib/SIL/IR/SILInstructions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3176,7 +3176,7 @@ KeyPathInst::create(SILDebugLocation Loc,
31763176
ArrayRef<SILValue> Args,
31773177
SILType Ty,
31783178
SILFunction &F) {
3179-
assert(Args.size() == Pattern->getNumOperands()
3179+
ASSERT(Args.size() == Pattern->getNumOperands()
31803180
&& "number of key path args doesn't match pattern");
31813181

31823182
SmallVector<SILValue, 8> allOperands(Args.begin(), Args.end());

0 commit comments

Comments
 (0)