[PATCH] D26595: IR: Change PointerType to derive from Type rather than SequentialType.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 13:07:37 PST 2016


pcc added inline comments.


================
Comment at: llvm/lib/IR/ConstantFold.cpp:2208-2212
-    if (isa<PointerType>(STy)) {
-      // We don't know if it's in range or not.
-      Unknown = true;
-      continue;
-    }
----------------
pcc wrote:
> dblaikie wrote:
> > Is there a guarantee that it's never really a pointer type here?
> The purpose of this loop is to look through a notional GEP's element types. Earlier we initialized `Ty` to `PointeeTy` which, at the only call site [0], is the notional GEP's source element type. Because the source element type cannot be a pointer, and the same goes for later element types, having a pointer type here is impossible and this was dead code before.
> 
> [0] http://llvm-cs.pcc.me.uk/lib/IR/Constants.cpp#1906
Correction: the loop only looks at indexable element types. Of course the source element type could be a pointer (or any other type) if the GEP has only one operand, and the target element type may be non-indexable regardless of the number of operands. But this loop has (operands-1) iterations (see line 2189 above), which means that we never look at the target element type.


https://reviews.llvm.org/D26595





More information about the llvm-commits mailing list