[llvm] [AA] Refine ModRefInfo taking into account `errnomem` location (PR #157495)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 14 13:58:34 PDT 2025
================
@@ -997,6 +998,18 @@ 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 alloca, 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 && !isa<AllocaInst>(Object) &&
----------------
nikic wrote:
Thinking about this more carefully, noalias arguments are fine as well. After all, errnomem would imply that errno is being accessed without going through the noalias argument, so that would be UB and we can exclude the possibility.
https://github.com/llvm/llvm-project/pull/157495
More information about the llvm-commits
mailing list