aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-02-28 20:56:12 +0000
committerGitHub <noreply@github.com>2025-02-28 20:56:12 +0000
commit275baedfde9dcd344bc4f11f552b046a69a4bf3f (patch)
treec714abdc2a939e40d11fa80788c6b820d1591327 /llvm/lib/Analysis/LoopAccessAnalysis.cpp
parent23efe734fc27544b473ad60ea6eecbd2ec66d20c (diff)
downloadllvm-275baedfde9dcd344bc4f11f552b046a69a4bf3f.zip
llvm-275baedfde9dcd344bc4f11f552b046a69a4bf3f.tar.gz
llvm-275baedfde9dcd344bc4f11f552b046a69a4bf3f.tar.bz2
[LAA] Consider accessed addrspace when mapping underlying obj to access. (#129087)
In some cases, it is possible for the same underlying object to be accessed via pointers to different address spaces. This could lead to pointers from different address spaces ending up in the same dependency set, which isn't allowed (and triggers an assertion). Update the mapping from underlying object -> last access to also include the accessing address space. Fixes https://github.com/llvm/llvm-project/issues/124759. PR: https://github.com/llvm/llvm-project/pull/129087
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index cf3bb6a..38ee82b 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1362,8 +1362,10 @@ void AccessAnalysis::processMemAccesses() {
bool SetHasWrite = false;
- // Map of pointers to last access encountered.
- typedef DenseMap<const Value*, MemAccessInfo> UnderlyingObjToAccessMap;
+ // Map of (pointer to underlying objects, accessed address space) to last
+ // access encountered.
+ typedef DenseMap<std::pair<const Value *, unsigned>, MemAccessInfo>
+ UnderlyingObjToAccessMap;
UnderlyingObjToAccessMap ObjToLastAccess;
// Set of access to check after all writes have been processed.
@@ -1443,8 +1445,10 @@ void AccessAnalysis::processMemAccesses() {
UnderlyingObj->getType()->getPointerAddressSpace()))
continue;
- auto [It, Inserted] =
- ObjToLastAccess.try_emplace(UnderlyingObj, Access);
+ auto [It, Inserted] = ObjToLastAccess.try_emplace(
+ {UnderlyingObj,
+ cast<PointerType>(Ptr->getType())->getAddressSpace()},
+ Access);
if (!Inserted) {
DepCands.unionSets(Access, It->second);
It->second = Access;