[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
This commit is contained in:
James Y Knight
2019-02-01 20:44:47 +00:00
parent 14359ef1b6
commit 7716075a17
35 changed files with 212 additions and 169 deletions

View File

@@ -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);