[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 committed 2021-06-21 20:06:25 +02:00
1 parent 0c09e5bd74
commit d9fe96fe26
5 files changed
+34 -11

No files matched your search

+3 -4
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");