From 7716075a1729ead67844574fdb34579894122992 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Fri, 1 Feb 2019 20:44:47 +0000 Subject: [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 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 014b56a..61bc031 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(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(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 Indices(Elts.begin() + 1, Elts.end()); V = ConstantExpr::getGetElementPtr(PointeeType, Elts[0], Indices, InBounds, InRangeIndex); -- cgit v1.1