1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-21 18:22:53 +01:00

[AA] Support callCapturesBefore() on BatchAA (NFCI)

This is not expected to have any practical compile-time effect,
as the alias() calls inside callCapturesBefore() are rare. This
should still be supported for API completeness, and might be
useful for reachability caching.
This commit is contained in:
Nikita Popov 2021-05-13 21:45:46 +02:00
parent 590113a40f
commit a09a84aaf6
3 changed files with 19 additions and 5 deletions

View File

@ -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<MemoryLocation> &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

View File

@ -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

View File

@ -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.