Make getModRefInfo with a default location not crash.

Add getModRefInfo that works without location.
Add unit tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234811 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Berlin
2015-04-13 23:05:45 +00:00
parent 534f9f3ee5
commit b4f6438352
4 changed files with 125 additions and 9 deletions
+12 -9
View File
@@ -330,7 +330,7 @@ AliasAnalysis::getModRefInfo(const LoadInst *L, const Location &Loc) {
// If the load address doesn't alias the given address, it doesn't read
// or write the specified memory.
if (!alias(getLocation(L), Loc))
if (Loc.Ptr && !alias(getLocation(L), Loc))
return NoModRef;
// Otherwise, a load just reads.
@@ -343,15 +343,18 @@ AliasAnalysis::getModRefInfo(const StoreInst *S, const Location &Loc) {
if (!S->isUnordered())
return ModRef;
// If the store address cannot alias the pointer in question, then the
// specified memory cannot be modified by the store.
if (!alias(getLocation(S), Loc))
return NoModRef;
if (Loc.Ptr) {
// If the store address cannot alias the pointer in question, then the
// specified memory cannot be modified by the store.
if (!alias(getLocation(S), Loc))
return NoModRef;
// If the pointer is a pointer to constant memory, then it could not have been
// modified by this store.
if (pointsToConstantMemory(Loc))
return NoModRef;
// If the pointer is a pointer to constant memory, then it could not have
// been modified by this store.
if (pointsToConstantMemory(Loc))
return NoModRef;
}
// Otherwise, a store just writes.
return Mod;