[PATCH] D61911: [GlobalOpt] Allow dead struct fields in SRA with non constant offset.

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 19:08:04 PDT 2019


hfinkel added a comment.

In D61911#1557985 <https://reviews.llvm.org/D61911#1557985>, @efriedma wrote:

> The problem here is that the IR semantics don't allow this transform in general.
>
> Even if you've managed to dodge the exact construct from bug 38309 (I'm not sure I understand how, but it's not really relevant), the rules for GEP indexing don't work the way you want them to.  "inbounds" just means the result is somewhere within the same global; it doesn't mean that array indexes don't "overflow".  See http://llvm.org/docs/LangRef.html#getelementptr-instruction .


The desire here is to look at constant GEPs? Maybe looking at the "inrange" keyword instead would be better (it has stronger semantics than inbounds), "If the inrange keyword is present before any index, loading from or storing to any pointer derived from the getelementptr has undefined behavior if the load or store would access memory outside of the bounds of the element selected by the index marked as inrange. " (also discussed in http://llvm.org/docs/LangRef.html#getelementptr-instruction).


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61911/new/

https://reviews.llvm.org/D61911





More information about the llvm-commits mailing list