[PATCH] D42123: Derive GEP index type from Data Layout

Elena Demikhovsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 10:20:32 PST 2018


delena added a comment.

In https://reviews.llvm.org/D42123#981602, @theraven wrote:

> I don't like this patch as is, for several reasons.
>
> 1. It's adding a hack that assumes that the offset should be the width of the widest integer operation.  This is probably true in most cases (it is for us), but if we're going to introduce the idea that an address offset is distinct from the size of the pointer then we should do it properly and add that to the TargetInfo string explicitly (defaulting to the same size, if not specified).


So you propose to extend Data Layout string and add index size to it, right? It was one of options that Hal suggested. Ok.

> 2. We're computing the correct width every time it's requested, which looks expensive.  TargetInfo should store the width for each address space and, for non-vector types, not have to do any calculation to determine the kind of integer to return.

We calculated getIntPtrType() anyway, getIndexType() is not more expensive. If I extend TargetInfo, the extension will be optional and all other targets will calculate getIntPtrType() anyway.

> 3. It fixes only around 20% of the places that we've found that assume that the size and range of the pointer are the same.

I can't derive all places from your code. You can show me them all, one-by-one, or we'll fix more places gradually on top of this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D42123





More information about the llvm-commits mailing list