[AliasAnalysis] Give back AA results for fence instructions
Calling getModRefInfo with a fence resulted in crashes because fences
don't have a memory location. Add a new predicate to Instruction
called isFenceLike which indicates that the instruction mutates memory
but not any single memory location in particular. In practice, it is a
proxy for the set of instructions which "mayWriteToMemory" but cannot be
used with MemoryLocation::get.
This fixes PR28570.
llvm-svn: 275581
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index ab5f814..f931b6f 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -111,6 +111,9 @@
if (auto CS = ImmutableCallSite(I)) {
// Check if the two calls modify the same memory
return getModRefInfo(CS, Call);
+ } else if (I->isFenceLike()) {
+ // If this is a fence, just return MRI_ModRef.
+ return MRI_ModRef;
} else {
// Otherwise, check if the call modifies or references the
// location this memory access defines. The best we can say