mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
LoopRotate: Fix a by reference map bug under reallocation
When using a densemap subscript expression on both sides of an assignment in the same statement of the same map we run into the issue that the map can reallocate because of the assignment but we are referencing the value of the RHS map subscript by reference -- i.e we can reference deallocated memory. Not good. My attempts at making a reproducer crash failed. rdar://151031297
This commit is contained in:
@@ -428,7 +428,8 @@ static bool rotateLoop(SILLoop *loop, DominanceInfo *domInfo,
|
||||
|
||||
for (auto &inst : *header) {
|
||||
if (auto *bfi = dyn_cast<BorrowedFromInst>(&inst)) {
|
||||
valueMap[bfi] = valueMap[bfi->getBorrowedValue()];
|
||||
auto mappedValue = valueMap[bfi->getBorrowedValue()];
|
||||
valueMap[bfi] = mappedValue;
|
||||
} else if (SILInstruction *cloned = inst.clone(preheaderBranch)) {
|
||||
mapOperands(cloned, valueMap);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user