[llvm-branch-commits] [llvm] [SDAG] Introduce inbounds flag for pointer arithmetic (PR #131862)

Eli Friedman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Mar 21 10:36:22 PDT 2025


efriedma-quic wrote:

If an pointer is constructed using inttoptr, it can be based on multiple objects.  (In IR, we can see the inttoptr, but in SelectionDAG, it's treated as a noop and eliminated.)

The "inbounds" rule should probably say something like this: "The base pointer must be based on one or more allocated objects for which the following applies: the base pointer has an *in bounds* address of the allocated object, and the resulting pointer is *in bounds* of the allocated object."

-----

Actually, thinking about it a bit more, the "allocated object" referenced in the LangRef spec doesn't actually have to be live.  So you also have to worry about objects which were previously allocated at the same address... which means inbounds is basically meaningless for a pointer created using inttoptr.

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


More information about the llvm-branch-commits mailing list