[PATCH] D22793: IR: Introduce inbounds attribute on getelementptr indices.

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 18:05:37 PDT 2016


sanjoy added inline comments.

================
Comment at: docs/LangRef.rst:7550
@@ +7549,3 @@
+a GEP which was evaluated with identical operands up to and including the
+``inrange`` operand. Note that the ``inrange`` keyword is currently only
+allowed in constant expressions.
----------------
sanjoy wrote:
> This is a little odd since (IIUC) it implies that replacing an `inrange` GEP with a not `inrange` version of the same GEP can introduce undefined behavior; that is:
> 
> ```
> x0 = gep_inrange(A, 42)
> x1 = gep_normal(A, 42)
> result = x0 == x0 ;; perhaps hidden behind a function
> ```
> 
> to
> 
> ```
> x0 = gep_inrange(A, 42)
> x1 = gep_normal(A, 42)
> result = x0 == y0 ;; perhaps hidden behind a function
> ```
> 
> via x1->replaceAllUsesWith(x0).
> 
> Why do you need this property / caveat?
There's a typo, in the transformed snippet we should have `result = x0 == x1`.  Also pretend that there are other uses of `x1` (so it isn't trivially DCE'ed away).


https://reviews.llvm.org/D22793





More information about the llvm-commits mailing list