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

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 17:30:36 PDT 2016


pcc added inline comments.

================
Comment at: docs/LangRef.rst:7549
@@ +7548,3 @@
+with the ``inrange`` keyword is undefined. Note that the ``inrange`` keyword
+is currently only allowed in constant ``getelementptr`` expressions.
+
----------------
mehdi_amini wrote:
> Isn't it hard to guarantee in face of transformations?
> 
> Let say a pass would do outlining, passing the pointer derived from the GEP by argument, in this new function the inrange information would be lost and another transformation allowed to introduce a pointer comparison.
Hrm, yes, I think you're right. It looks like we can't avoid specifying exactly which comparisons are allowable in practice.

Taking into account Sanjoy's point from earlier, I believe this would suffice:

```
The result of a pointer
comparison or ``ptrtoint`` involving a pointer derived from a ``getelementptr``
with the ``inrange`` keyword is undefined, with the exception of comparisons in the case
where both operands are in the range of the element selected by the ``inrange`` keyword,
inclusive of the address one past the end of that element.
```


https://reviews.llvm.org/D22793





More information about the llvm-commits mailing list