summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2019-02-01 20:44:47 +0000
committerJames Y Knight <jyknight@google.com>2019-02-01 20:44:47 +0000
commit7716075a1729ead67844574fdb34579894122992 (patch)
tree1a3b91f53223202ab65c910dbc26979f5f05201c /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent14359ef1b6a0610ac91df5f5a91c88a0b51c187c (diff)
downloadbcm5719-llvm-7716075a1729ead67844574fdb34579894122992.tar.gz
bcm5719-llvm-7716075a1729ead67844574fdb34579894122992.zip
[opaque pointer types] Pass value type to GetElementPtr creation.
This cleans up all GetElementPtr creation in LLVM to explicitly pass a value type rather than deriving it from the pointer's element-type. Differential Revision: https://reviews.llvm.org/D57173 llvm-svn: 352913
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 014b56a8cf7..61bc031026b 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2424,16 +2424,18 @@ Error BitcodeReader::parseConstants() {
Elts.push_back(ValueList.getConstantFwdRef(Record[OpNum++], ElTy));
}
- if (PointeeType &&
- PointeeType !=
- cast<PointerType>(Elts[0]->getType()->getScalarType())
- ->getElementType())
- return error("Explicit gep operator type does not match pointee type "
- "of pointer operand");
-
if (Elts.size() < 1)
return error("Invalid gep with no operands");
+ Type *ImplicitPointeeType =
+ cast<PointerType>(Elts[0]->getType()->getScalarType())
+ ->getElementType();
+ if (!PointeeType)
+ PointeeType = ImplicitPointeeType;
+ else if (PointeeType != ImplicitPointeeType)
+ return error("Explicit gep operator type does not match pointee type "
+ "of pointer operand");
+
ArrayRef<Constant *> Indices(Elts.begin() + 1, Elts.end());
V = ConstantExpr::getGetElementPtr(PointeeType, Elts[0], Indices,
InBounds, InRangeIndex);
OpenPOWER on IntegriCloud