Revert "[IR] Don't accept nullptr as GEP element type"

This reverts commit 5035e7be1a.

This change broke several lldb bots.
This commit is contained in:
Stella Stamenova 2021-07-09 11:32:39 -07:00
parent 739f49ed12
commit a821df993d
1 changed files with 14 additions and 6 deletions

View File

@ -956,9 +956,13 @@ public:
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
unsigned Values = 1 + unsigned(IdxList.size());
assert(PointeeType && "Must specify element type");
assert(cast<PointerType>(Ptr->getType()->getScalarType())
->isOpaqueOrPointeeTypeMatches(PointeeType));
if (!PointeeType) {
PointeeType =
cast<PointerType>(Ptr->getType()->getScalarType())->getElementType();
} else {
assert(cast<PointerType>(Ptr->getType()->getScalarType())
->isOpaqueOrPointeeTypeMatches(PointeeType));
}
return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
NameStr, InsertBefore);
}
@ -968,9 +972,13 @@ public:
const Twine &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Values = 1 + unsigned(IdxList.size());
assert(PointeeType && "Must specify element type");
assert(cast<PointerType>(Ptr->getType()->getScalarType())
->isOpaqueOrPointeeTypeMatches(PointeeType));
if (!PointeeType) {
PointeeType =
cast<PointerType>(Ptr->getType()->getScalarType())->getElementType();
} else {
assert(cast<PointerType>(Ptr->getType()->getScalarType())
->isOpaqueOrPointeeTypeMatches(PointeeType));
}
return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
NameStr, InsertAtEnd);
}