aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-03-19 15:44:52 +0100
committerGitHub <noreply@github.com>2025-03-19 15:44:52 +0100
commit38e8dff84ba1e2cf0260712d21dd429d74471d08 (patch)
treeb8c687e292b8e1313e36a18379f4190ea309042b /llvm/lib/Analysis/AliasAnalysis.cpp
parent67a01131a8d70fcd06c6bd9cea30a8a6262c8c94 (diff)
downloadllvm-38e8dff84ba1e2cf0260712d21dd429d74471d08.zip
llvm-38e8dff84ba1e2cf0260712d21dd429d74471d08.tar.gz
llvm-38e8dff84ba1e2cf0260712d21dd429d74471d08.tar.bz2
[AA][BasicAA] Move more call logic to BasicAA (#131144)
Currently, the handling for calls is split between AA and BasicAA in an awkward way. BasicAA does argument alias analysis for non-escaping objects (but without considering MemoryEffects), while AA handles the generic case using MemoryEffects. However, fundamentally, both of these are really trying to do the same thing. The new merged logic first tries to remove the OtherMR component of the memory effects, which includes accesses to escaped memory. If a function-local object does not escape, OtherMR can be set to NoModRef. Then we perform the argument scan in basically the same way as AA previously did. However, we also need to look at the operand bundles. To support that, I've adjusted getArgModRefInfo to accept operand bundle arguments.
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/AliasAnalysis.cpp32
1 files changed, 0 insertions, 32 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 5114137..9573da9 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -220,38 +220,6 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call,
return ModRefInfo::NoModRef;
}
- // Try to refine the mod-ref info further using other API entry points to the
- // aggregate set of AA results.
-
- // We can completely ignore inaccessible memory here, because MemoryLocations
- // can only reference accessible memory.
- auto ME = getMemoryEffects(Call, AAQI)
- .getWithoutLoc(IRMemLocation::InaccessibleMem);
- if (ME.doesNotAccessMemory())
- return ModRefInfo::NoModRef;
-
- ModRefInfo ArgMR = ME.getModRef(IRMemLocation::ArgMem);
- ModRefInfo OtherMR = ME.getWithoutLoc(IRMemLocation::ArgMem).getModRef();
- if ((ArgMR | OtherMR) != OtherMR) {
- // Refine the modref info for argument memory. We only bother to do this
- // if ArgMR is not a subset of OtherMR, otherwise this won't have an impact
- // on the final result.
- ModRefInfo AllArgsMask = ModRefInfo::NoModRef;
- for (const auto &I : llvm::enumerate(Call->args())) {
- const Value *Arg = I.value();
- if (!Arg->getType()->isPointerTy())
- continue;
- unsigned ArgIdx = I.index();
- MemoryLocation ArgLoc = MemoryLocation::getForArgument(Call, ArgIdx, TLI);
- AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI, Call);
- if (ArgAlias != AliasResult::NoAlias)
- AllArgsMask |= getArgModRefInfo(Call, ArgIdx);
- }
- ArgMR &= AllArgsMask;
- }
-
- Result &= ArgMR | OtherMR;
-
// Apply the ModRef mask. This ensures that if Loc is a constant memory
// location, we take into account the fact that the call definitely could not
// modify the memory location.