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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 12:42:05 PDT 2016


eli.friedman added a comment.

(I'll refer to the new attribute as inrange to try to avoid confusion.)

Does the way you're using subclass data mean that GVN just works correctly without any additional changes?  Or does it need to be modified to avoid unifying a non-inrange GEP with an inrange GEP?

inrange markings probably interact badly with certain existing optimizations; for example, a gep with all zero indexes plus a bitcast currently gets folded into just a bitcast, but that loses the inrange marking.  Not a correctness problem, but it'll probably be difficult to fix the resulting missed optimizations.

We'll probably have to be extremely cautious in terms of how we actually use inrange in clang.  Applying inrange to a computation like "&p->a" is theoretically allowed by the C standard, but likely to cause problems in practice.  Specifically, we could end up breaking programs without any good way to find the problem.  Existing tools like valgrind and asan can't detect this sort of issue at all.  That's more of a question of what makes sense for clang rather than something which affects the attribute itself... but if clang can't really use inrange markings outside of vtables, that reduces the utility a lot.


https://reviews.llvm.org/D22793





More information about the llvm-commits mailing list