[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user