[PATCH] D21928: Aliasing of constant pointers (inttoptr Const) for BasicAA

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 09:37:33 PDT 2016

eli.friedman added a comment.

Please ignore my previous comments, they were overly terse and not quite correct.

Analyzing the numeric value of a pointer to determine two pointers are noalias is not safe, period.

On most operating systems, you can mmap() a page of memory to multiple addresses, and users will expect it to point to the same memory.  The C++ standard addresses this explicitly for atomic operations: "Operations that are lock-free should also be address-free. That is, atomic operations on the same memory location via two different addresses will communicate atomically."

If you're dealing with unusual addressing systems, the pointer value also can't be used like this because the pointer could contain metadata that doesn't actually affect to the memory location.

It should be okay to determine that two pointers with the same value are MustAlias... but we already perform that check (see isValueEqualInPotentialCycles).

You could write a patch to return PartialAlias results for constant integer pointers where we can prove overlap, I guess.


More information about the llvm-commits mailing list