[llvm] [BasicAA][TLI] Treat local-linkage globals or known environments as not aliasing errno (PR #170290)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 4 04:09:29 PST 2026
================
@@ -1862,16 +1862,31 @@ AliasResult BasicAAResult::aliasCheckRecursive(
}
AliasResult BasicAAResult::aliasErrno(const MemoryLocation &Loc,
- const Module *M) {
+ const CallBase *Call) {
// There cannot be any alias with errno if the given memory location is an
// identified function-local object, or the size of the memory access is
// larger than the integer size.
if (Loc.Size.hasValue() &&
Loc.Size.getValue().getKnownMinValue() * 8 > TLI.getIntSize())
return AliasResult::NoAlias;
- if (isIdentifiedFunctionLocal(getUnderlyingObject(Loc.Ptr)))
+ const Value *Object = getUnderlyingObject(Loc.Ptr);
+ if (isIdentifiedFunctionLocal(Object))
return AliasResult::NoAlias;
+
+ if (auto *GV = dyn_cast<GlobalVariable>(Object)) {
+ // Errno cannot alias internal/private globals.
+ if (GV->hasLocalLinkage())
----------------
antoniofrighetto wrote:
Moved on top. I'm not completely sure under which conditions this could happen (in LTO), but I think it makes sense (also refined the comment, please see if that confirms my understanding).
https://github.com/llvm/llvm-project/pull/170290
More information about the llvm-commits
mailing list