diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index 79e99075921..7fec0feb09d 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -795,7 +795,11 @@ public: /// 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 @@ private: 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 @@ public: 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/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index 9174184c193..e7445e225d5 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/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/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 356dd2d06cb..5f46db204fb 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/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.