[sil-aa] Add in convenience methods for querying AliasAnalysis::getMemoryBehavior.

The methods are:

 * mayWriteToMemory()
 * mayReadFromMemory()
 * mayReadOrWriteMemory()
 * mayHaveSideEffects() [Side effects + writing to memory]
 * mayHavePureSideEffects() [Only side effects, ignores writes to memory]

Swift SVN r13791
This commit is contained in:
Michael Gottesman
2014-02-12 00:14:29 +00:00
parent 016d62d930
commit fbe2ccf0d6
3 changed files with 40 additions and 39 deletions

View File

@@ -35,18 +35,6 @@ STATISTIC(NumForwardedLoads, "Number of loads forwarded");
// Utility Functions
//===----------------------------------------------------------------------===//
static bool isWriteMemBehavior(SILInstruction::MemoryBehavior B) {
switch (B) {
case SILInstruction::MemoryBehavior::MayWrite:
case SILInstruction::MemoryBehavior::MayReadWrite:
case SILInstruction::MemoryBehavior::MayHaveSideEffects:
return true;
case SILInstruction::MemoryBehavior::None:
case SILInstruction::MemoryBehavior::MayRead:
return false;
}
}
/// Given the already emitted load PrevLI, see if we can find a projection
/// address path to LI. If we can, emit the corresponding aggregate projection
/// insts and return the last such inst.
@@ -98,7 +86,7 @@ invalidateAliasingLoads(SILInstruction *Inst,
AliasAnalysis *AA) {
llvm::SmallVector<LoadInst *, 4> InvalidatedLoadList;
for (auto *LI : Loads)
if (isWriteMemBehavior(AA->getMemoryBehavior(Inst, LI->getOperand())))
if (AA->mayWriteToMemory(Inst, LI->getOperand()))
InvalidatedLoadList.push_back(LI);
for (auto *LI : InvalidatedLoadList) {
DEBUG(llvm::dbgs() << " Found an instruction that writes to memory "