Skip to content

Commit d08e075

Browse files
committed
[sil-cloner] Be careful when during the cloning process one instruction is mapped to multiple new instructions
Fixes a long-standing bug in the SIL cloner.
1 parent af2a596 commit d08e075

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ SILCloner<ImplClass>::postProcess(SILInstruction *Orig,
384384
SILInstruction *Cloned) {
385385
assert((Orig->getDebugScope() ? Cloned->getDebugScope()!=nullptr : true) &&
386386
"cloned function dropped debug scope");
387+
// Remove any previous mappings for the Orig instruction.
388+
// If this is not done and there is a mapping for Orig in the map already,
389+
// then this new mapping will be silently ignored.
390+
InstructionMap.erase(Orig);
387391
InstructionMap.insert(std::make_pair(Orig, Cloned));
388392
}
389393

0 commit comments

Comments
 (0)