Defs->push_back(*NewAccess);
}
}
+ BlockNumberingValid.erase(BB);
}
void MemorySSA::insertIntoListsBefore(MemoryAccess *What, const BasicBlock *BB,
Defs->insert(InsertPt->getDefsIterator(), *What);
}
}
+ BlockNumberingValid.erase(BB);
}
// Move What before Where in the IR. The end result is taht What will belong to
insertIntoListsBefore(What, BB, Where);
}
+void MemorySSA::moveTo(MemoryUseOrDef *What, BasicBlock *BB,
+ InsertionPlace Point) {
+ removeFromLists(What, false);
+ What->setBlock(BB);
+ insertIntoListsForBlock(What, BB, Point);
+}
+
MemoryPhi *MemorySSA::createMemoryPhi(BasicBlock *BB) {
assert(!getMemoryAccess(BB) && "MemoryPhi already exists for this BB");
MemoryPhi *Phi = new MemoryPhi(BB->getContext(), BB, NextID++);
+ // Phi's always are placed at the front of the block.
insertIntoListsForBlock(Phi, BB, Beginning);
ValueToMemoryAccess[BB] = Phi;
- // Phi's always are placed at the front of the block.
- BlockNumberingValid.erase(BB);
return Phi;
}
InsertionPlace Point) {
MemoryUseOrDef *NewAccess = createDefinedAccess(I, Definition);
insertIntoListsForBlock(NewAccess, BB, Point);
- BlockNumberingValid.erase(BB);
return NewAccess;
}
assert(I->getParent() == InsertPt->getBlock() &&
"New and old access must be in the same block");
MemoryUseOrDef *NewAccess = createDefinedAccess(I, Definition);
- BlockNumberingValid.erase(InsertPt->getBlock());
insertIntoListsBefore(NewAccess, InsertPt->getBlock(),
InsertPt->getIterator());
return NewAccess;
assert(I->getParent() == InsertPt->getBlock() &&
"New and old access must be in the same block");
MemoryUseOrDef *NewAccess = createDefinedAccess(I, Definition);
- BlockNumberingValid.erase(InsertPt->getBlock());
insertIntoListsBefore(NewAccess, InsertPt->getBlock(),
++(InsertPt->getIterator()));
return NewAccess;
// of that thing with us, since we are in the way of whatever was there
// before.
// We now define that def's memorydefs and memoryphis
- for (auto UI = DefBefore->use_begin(), UE = DefBefore->use_end(); UI != UE;) {
- Use &U = *UI++;
- // Leave the uses alone
- if (isa<MemoryUse>(U.getUser()))
- continue;
- U.set(MD);
+ if (DefBeforeSameBlock) {
+ for (auto UI = DefBefore->use_begin(), UE = DefBefore->use_end();
+ UI != UE;) {
+ Use &U = *UI++;
+ // Leave the uses alone
+ if (isa<MemoryUse>(U.getUser()))
+ continue;
+ U.set(MD);
+ }
}
+
// and that def is now our defining access.
// We change them in this order otherwise we will appear in the use list
// above and reset ourselves.