[OpaquePtr] Support opaque constant expression GEP

Adjust assertions to use isOpaqueOrPointeeTypeMatches() and make
it return an opaque pointer result for an opaque base pointer. We
also need to enumerate the element type, as it is no longer
implicitly enumerated through the pointer type.

Differential Revision: https://reviews.llvm.org/D104655
This commit is contained in:
Nikita Popov
2021-06-21 18:33:29 +02:00
parent 0c09e5bd74
commit d9fe96fe26
5 changed files with 34 additions and 11 deletions

View File

@@ -2663,11 +2663,10 @@ Error BitcodeReader::parseConstants() {
if (Elts.size() < 1)
return error("Invalid gep with no operands");
Type *ImplicitPointeeType =
cast<PointerType>(Elt0FullTy->getScalarType())->getElementType();
PointerType *OrigPtrTy = cast<PointerType>(Elt0FullTy->getScalarType());
if (!PointeeType)
PointeeType = ImplicitPointeeType;
else if (PointeeType != ImplicitPointeeType)
PointeeType = OrigPtrTy->getElementType();
else if (!OrigPtrTy->isOpaqueOrPointeeTypeMatches(PointeeType))
return error("Explicit gep operator type does not match pointee type "
"of pointer operand");