[PATCH] D82061: [IR] Prefer scalar type for struct indexes in GEP constant expressions.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 18 12:01:29 PDT 2020
efriedma marked an inline comment as done.
efriedma added inline comments.
================
Comment at: llvm/lib/IR/Constants.cpp:2178
ArgVec.push_back(C);
- for (unsigned i = 0, e = Idxs.size(); i != e; ++i) {
+ generic_gep_type_iterator<Value* const*>
+ GTI = gep_type_begin(Ty, Idxs),
----------------
ctetreau wrote:
> efriedma wrote:
> > ctetreau wrote:
> > > ctetreau wrote:
> > > > can this use `auto`?
> > > what is the change to iterators from indices buying us?
> > I think this can use auto, yes.
> >
> > The point of using the iterators is that they provide the isStruct() and isSequential() methods.
> Could these not be replaced by isa checks? isSequential seems especially useless since it checks that the thing is a `Type *`
At a high level, generic_gep_type_iterator takes a GEP base type and some indexes, and steps through the indexed types. The computed types can be queried with isStruct()/isSequential()/etc. This is information which we can't get directly from the indexes themselves.
At a low level, I think you're misreading the implementation of generic_gep_type_iterator; look at the documentation for PointerUnion.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82061/new/
https://reviews.llvm.org/D82061
More information about the llvm-commits
mailing list