[OpaquePtr][BitcodeWriter] Handle attributes with types

For example, byval.

Skip the type attribute auto-upgrade if we already have the type.

I've actually seen this error of the ValueEnumerator missing a type
attribute's type in a non-opaque pointer context.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D105138
This commit is contained in:
Arthur Eubanks 2021-06-29 11:38:18 -07:00
parent b810600a93
commit cb3580e7ad
3 changed files with 13 additions and 0 deletions

View File

@ -3333,6 +3333,9 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
if (!Func->hasParamAttribute(i, Kind))
continue;
if (Func->getParamAttribute(i, Kind).getValueAsType())
continue;
Func->removeParamAttr(i, Kind);
Type *PTy = cast<FunctionType>(FTy)->getParamType(i);

View File

@ -1045,6 +1045,11 @@ void ValueEnumerator::EnumerateAttributes(AttributeList PAL) {
if (Entry == 0) {
AttributeGroups.push_back(Pair);
Entry = AttributeGroups.size();
for (Attribute Attr : AS) {
if (Attr.isTypeAttribute())
EnumerateType(Attr.getValueAsType());
}
}
}
}

View File

@ -141,3 +141,8 @@ cleanup:
cleanup
ret void
}
; CHECK: define void @byval(ptr byval({ i32, i32 }) %0)
define void @byval(ptr byval({ i32, i32 }) %0) {
ret void
}