[llvm] 570fffe - [MemorySSA] Relax clobbering checks for calls to consider writes only (#179721)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 01:19:06 PST 2026


Author: CarolineConcatto
Date: 2026-02-10T09:19:01Z
New Revision: 570fffe04480133edc2df29eb018754c7a3e896b

URL: https://github.com/llvm/llvm-project/commit/570fffe04480133edc2df29eb018754c7a3e896b
DIFF: https://github.com/llvm/llvm-project/commit/570fffe04480133edc2df29eb018754c7a3e896b.diff

LOG: [MemorySSA] Relax clobbering checks for calls to consider writes only (#179721)

Now that getModRefInfo for calls handles read and write effects by
examining both calls, the clobbering query no longer needs to treat
reads as clobbers. Update the check to consider writes only, aligning
call handling with other instructions

Added: 
    

Modified: 
    llvm/lib/Analysis/MemorySSA.cpp
    llvm/test/Analysis/MemorySSA/function-clobber.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index 0b2e3fcfd76df..4f03080d9af67 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -312,7 +312,7 @@ instructionClobbersQuery(const MemoryDef *MD, const MemoryLocation &UseLoc,
 
   if (auto *CB = dyn_cast_or_null<CallBase>(UseInst)) {
     ModRefInfo I = AA.getModRefInfo(DefInst, CB);
-    return isModOrRefSet(I);
+    return isModSet(I);
   }
 
   if (auto *DefLoad = dyn_cast<LoadInst>(DefInst))

diff  --git a/llvm/test/Analysis/MemorySSA/function-clobber.ll b/llvm/test/Analysis/MemorySSA/function-clobber.ll
index 93e8715c7da60..1cdc32e2867e4 100644
--- a/llvm/test/Analysis/MemorySSA/function-clobber.ll
+++ b/llvm/test/Analysis/MemorySSA/function-clobber.ll
@@ -51,3 +51,16 @@ if.end:
   call void @readEverything()
   ret void
 }
+
+declare void @fn(ptr %p)
+
+define void @baz(ptr %p) {
+; CHECK:      1 = MemoryDef(liveOnEntry)
+; CHECK-NEXT: call void @fn(ptr %p)
+  call void @fn(ptr %p) memory(argmem: read, inaccessiblemem: readwrite)
+
+; CHECK:      MemoryUse(liveOnEntry)
+; CHECK-NEXT: call void @fn(ptr %p)
+  call void @fn(ptr %p) memory(argmem: read)
+  ret void
+}


        


More information about the llvm-commits mailing list