[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Thu May 29 12:04:54 PDT 2025
================
@@ -970,6 +971,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 alloca, the size of the memory access is
+ // larger than `sizeof(int)` or if TBAA proves it does not alias errno.
+ if ((ErrnoMR | OtherMR) != OtherMR) {
+ bool IsLocSizeUnknown = Loc.Size == MemoryLocation::UnknownSize;
+ if (ErrnoMR == ModRefInfo::Mod && !isa<AllocaInst>(Object) &&
+ (IsLocSizeUnknown ||
+ (!IsLocSizeUnknown && Loc.Size.getValue() <= sizeof(int))) &&
+ AAQI.AAR.aliasErrno(Loc, Call->getModule()) != AliasResult::NoAlias)
----------------
nikic wrote:
Also, possibly these extra checks should be in BasicAA::aliasErrno instead?
https://github.com/llvm/llvm-project/pull/125258
More information about the cfe-commits
mailing list