diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h index 79e99075921849..7fec0feb09d5b9 100644 --- a/llvm/include/llvm/Analysis/AliasAnalysis.h +++ b/llvm/include/llvm/Analysis/AliasAnalysis.h @@ -795,7 +795,11 @@ class AAResults { /// Early exits in callCapturesBefore may lead to ModRefInfo::Must not being /// set. ModRefInfo callCapturesBefore(const Instruction *I, - const MemoryLocation &MemLoc, DominatorTree *DT); + const MemoryLocation &MemLoc, + DominatorTree *DT) { + AAQueryInfo AAQIP; + return callCapturesBefore(I, MemLoc, DT, AAQIP); + } /// A convenience wrapper to synthesize a memory location. ModRefInfo callCapturesBefore(const Instruction *I, const Value *P, @@ -864,6 +868,9 @@ class AAResults { ModRefInfo getModRefInfo(const Instruction *I, const Optional &OptLoc, AAQueryInfo &AAQIP); + ModRefInfo callCapturesBefore(const Instruction *I, + const MemoryLocation &MemLoc, DominatorTree *DT, + AAQueryInfo &AAQIP); class Concept; @@ -925,6 +932,11 @@ class BatchAAResults { MemoryLocation(V2, LocationSize::precise(1))) == AliasResult::MustAlias; } + ModRefInfo callCapturesBefore(const Instruction *I, + const MemoryLocation &MemLoc, + DominatorTree *DT) { + return AA.callCapturesBefore(I, MemLoc, DT, AAQI); + } }; /// Temporary typedef for legacy code that uses a generic \c AliasAnalysis diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 9174184c193b4c..e7445e225d529b 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -718,7 +718,8 @@ ModRefInfo AAResults::getModRefInfo(const Instruction *I, /// with a smarter AA in place, this test is just wasting compile time. ModRefInfo AAResults::callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, - DominatorTree *DT) { + DominatorTree *DT, + AAQueryInfo &AAQI) { if (!DT) return ModRefInfo::ModRef; @@ -749,7 +750,9 @@ ModRefInfo AAResults::callCapturesBefore(const Instruction *I, !Call->isByValArgument(ArgNo))) continue; - AliasResult AR = alias(*CI, Object); + AliasResult AR = alias( + MemoryLocation::getBeforeOrAfter(*CI), + MemoryLocation::getBeforeOrAfter(Object), AAQI); // If this is a no-capture pointer argument, see if we can tell that it // is impossible to alias the pointer we're checking. If not, we have to // assume that the call could touch the pointer, even though it doesn't diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 356dd2d06cbf49..5f46db204fbafa 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -608,8 +608,7 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom( ModRefInfo MR = BatchAA.getModRefInfo(Inst, MemLoc); // If necessary, perform additional analysis. if (isModAndRefSet(MR)) - // TODO: Support callCapturesBefore() on BatchAAResults. - MR = AA.callCapturesBefore(Inst, MemLoc, &DT); + MR = BatchAA.callCapturesBefore(Inst, MemLoc, &DT); switch (clearMust(MR)) { case ModRefInfo::NoModRef: // If the call has no effect on the queried pointer, just ignore it.