[llvm-dev] Why does GEP allow src and destination type to have different address spaces?
Sanjoy Das via llvm-dev
llvm-dev at lists.llvm.org
Sun Oct 15 14:12:48 PDT 2017
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
More information about the llvm-dev
mailing list