[llvm] [LAA] Avoid duplicate runtime-check group members (PR #226829)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 00:27:08 PDT 2026


================
@@ -764,22 +764,24 @@ void RuntimePointerChecking::groupChecks(
     }
 
     SmallVector<RuntimeCheckingPtrGroup, 2> Groups;
+    SmallPtrSet<Value *, 2> SeenPointers;
 
     // Because DepCands is constructed by visiting accesses in the order in
     // which they appear in alias sets (which is deterministic) and the
     // iteration order within an equivalence class member is only dependent on
     // the order in which unions and insertions are performed on the
     // equivalence class, the iteration order is deterministic.
     for (auto M : DepCands.members(Access)) {
-      auto PointerI = PositionMap.find(M.getPointer());
-      // If we can't find the pointer in PositionMap that means we can't
-      // generate a memcheck for it.
-      if (PointerI == PositionMap.end())
+      Value *Pointer = M.getPointer();
+      // A read-modify-write access appears in DepCands in both access modes.
+      if (!SeenPointers.insert(Pointer).second)
         continue;
----------------
artagnon wrote:

```suggestion
```

What I meant is that we don't need to check SeenPointers? -- sorry, the previous suggestion wasn't clear, but SeenPointers should be subsumed by SeenIndices:

```cpp
  for (unsigned I = 0; I < Pointers.size(); ++I)
    PointerToIndices[Pointers[I].PointerValue].push_back(I);
```

All the SeenPointers are available as PointerToIndices.values() and I think this early-continue isn't needed at all?

https://github.com/llvm/llvm-project/pull/226829


More information about the llvm-commits mailing list