[llvm-dev] Why does GEP allow src and destination type to have different address spaces?

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Sun Oct 22 00:19:12 PDT 2017


The mail subject mentioned "address space", I don't know if Siddharth want
to check getPointerAddressSpace equal or not.

Regards,
chenwj

2017-10-16 5:12 GMT+08:00 Sanjoy Das via llvm-dev <llvm-dev at lists.llvm.org>:

> Adding this assert SGTM, but it looks like something like this is already
> there?
>
>   static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
>                                    ArrayRef<Value *> IdxList,
>                                    const Twine &NameStr = "",
>                                    Instruction *InsertBefore = nullptr) {
>     unsigned Values = 1 + unsigned(IdxList.size());
>     if (!PointeeType)
>       PointeeType =
>           cast<PointerType>(Ptr->getType()->getScalarType())->
> getElementType();
>     else
>       assert(
>           PointeeType ==
>           cast<PointerType>(Ptr->getType()->getScalarType())->
> getElementType());
>     return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList,
> Values,
>                                           NameStr, InsertBefore);
>   }
>
> Or did I misunderstand what you're suggesting?
>
> -- Sanjoy
>
> On Fri, Oct 13, 2017 at 3:59 PM, Siddharth Bhat via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > The GEP constructor does not assert that the source and destination types
> > match. Of course, this is incorrect and causes random failures somewhere
> > down the line.
> >
> > Could I add general sanity checks to the GEP constructor?
> >
> > In general, is an Instruction allowed to be in an inconsistent state? If
> so,
> > is there some well known method to "verify" whether an instruction is
> > consistent or not?
> >
> > Thanks,
> > ~Siddharth
> > --
> > Sending this from my phone, please excuse any typos!
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>



-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171022/7784a08a/attachment.html>


More information about the llvm-dev mailing list