[llvm] [InferAttrs] malloc-family libcalls may write `errnomem` location (PR #164382)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 12 09:30:23 PST 2025


antoniofrighetto wrote:

> Reviewing llvm-opt-benchmark diffs:
> 
> * A somewhat common regression are reloads from globals. Errno clearly can't alias an internal global. (Maybe this can also be extended to external globals if we look at the name.)

Thanks, it looks like the new AA changes would solve this (https://github.com/dtcxzyw/llvm-opt-benchmark/pull/3153).

> * Very common is something like a `load i32 (gep inbounds p, offset)`. It would be nice if we could exclude those cases, but I'm not sure we can (if the errno implementation is not opaque, then it might involve reading errno from a larger structure).

Good point. I wonder if we might pass through TLI for some libc. errno seems to be implemented as a simple `__thread int` in glibc, though, under the hood, at least on x86-64, thread-local vars are handled via `tcbhead_t` struct (in practice, I think we cannot say anything); and, as you were suggesting, musl indeed seems to implement errno as a field of `struct pthread`.


https://github.com/llvm/llvm-project/pull/164382


More information about the llvm-commits mailing list