Siddharth Bhat via llvm-dev
2017-Oct-13 22:59 UTC
[llvm-dev] Why does GEP allow src and destination type to have different address spaces?
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! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171013/45f2c0ec/attachment.html>
Sanjoy Das via llvm-dev
2017-Oct-15 21:12 UTC
[llvm-dev] Why does GEP allow src and destination type to have different address spaces?
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
陳韋任 via llvm-dev
2017-Oct-22 07:19 UTC
[llvm-dev] Why does GEP allow src and destination type to have different address spaces?
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>