[llvm] [LLVM] Relax clobbering checks for calls to consider writes only (PR #179721)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 9 01:58:21 PST 2026
https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/179721
>From 94337838f0c7d1868bb79a69f6b61d94f3485845 Mon Sep 17 00:00:00 2001
From: CarolineConcatto <caroline.concatto at arm.com>
Date: Wed, 4 Feb 2026 10:20:12 +0000
Subject: [PATCH] [LLVM] Relax clobbering checks for calls to consider writes
only
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
I was not able to produce a test that exercises this change with the
current setup. The change becomes relevant once target-specific memory
locations are introduced, which is the motivation for adding the test.
---
llvm/lib/Analysis/MemorySSA.cpp | 2 +-
llvm/test/Analysis/MemorySSA/function-clobber.ll | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
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