[llvm] a821df9 - Revert "[IR] Don't accept nullptr as GEP element type"
Stella Stamenova via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 9 11:33:27 PDT 2021
Author: Stella Stamenova
Date: 2021-07-09T11:32:39-07:00
New Revision: a821df993def459009a0d8263af879fc35400a94
URL: https://github.com/llvm/llvm-project/commit/a821df993def459009a0d8263af879fc35400a94
DIFF: https://github.com/llvm/llvm-project/commit/a821df993def459009a0d8263af879fc35400a94.diff
LOG: Revert "[IR] Don't accept nullptr as GEP element type"
This reverts commit 5035e7be1a8ab923e1a82def7e313cc11c0b176f.
This change broke several lldb bots.
Added:
Modified:
llvm/include/llvm/IR/Instructions.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 0c43a56daa33..a5cebf0a4626 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -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);
}
@@ -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);
}
More information about the llvm-commits
mailing list