[llvm] [AA] Refine ModRefInfo taking into account `errnomem` location (PR #157495)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 02:01:39 PDT 2025
================
@@ -997,6 +998,19 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
}
ModRefInfo Result = ArgMR | OtherMR;
+
+ // Refine writes to errno memory. We can safely exclude the errno location if
+ // the given memory location is an identified function-local object, the size
+ // of the memory access is larger than the integer size, or if TBAA proves it
+ // does not alias errno.
+ if ((ErrnoMR | Result) != Result) {
+ if (ErrnoMR == ModRefInfo::Mod && !isIdentifiedFunctionLocal(Object) &&
----------------
antoniofrighetto wrote:
I have been thinking on this, I expected we would model libc routines with write-only access kind to errno, so refining exclusively writes seemed reasonable. Thinking more, we shouldn't be relying on libcalls summaries here, the function may indeed happen to be annotated with errnomem: readwrite.
https://github.com/llvm/llvm-project/pull/157495
More information about the llvm-commits
mailing list