Skip to content

Commit

Permalink
Revert "[IR] Don't accept nullptr as GEP element type"
Browse files Browse the repository at this point in the history
This reverts commit 5035e7b.

This change broke several lldb bots.
  • Loading branch information
sstamenova committed Jul 9, 2021
1 parent 739f49e commit a821df9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions llvm/include/llvm/IR/Instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,13 @@ class GetElementPtrInst : public Instruction {
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);
}
Expand All @@ -968,9 +972,13 @@ class GetElementPtrInst : public Instruction {
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);
}
Expand Down

0 comments on commit a821df9

Please sign in to comment.