aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index f6f0c92..5a667f5 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4086,15 +4086,14 @@ Error BitcodeReader::typeCheckLoadStoreInst(Type *ValType, Type *PtrType) {
Error BitcodeReader::propagateAttributeTypes(CallBase *CB,
ArrayRef<unsigned> ArgTyIDs) {
+ AttributeList Attrs = CB->getAttributes();
for (unsigned i = 0; i != CB->arg_size(); ++i) {
for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet,
Attribute::InAlloca}) {
- if (!CB->paramHasAttr(i, Kind) ||
- CB->getParamAttr(i, Kind).getValueAsType())
+ if (!Attrs.hasParamAttr(i, Kind) ||
+ Attrs.getParamAttr(i, Kind).getValueAsType())
continue;
- CB->removeParamAttr(i, Kind);
-
Type *PtrEltTy = getPtrElementTypeByID(ArgTyIDs[i]);
if (!PtrEltTy)
return error("Missing element type for typed attribute upgrade");
@@ -4114,7 +4113,7 @@ Error BitcodeReader::propagateAttributeTypes(CallBase *CB,
llvm_unreachable("not an upgraded type attribute");
}
- CB->addParamAttr(i, NewAttr);
+ Attrs = Attrs.addParamAttribute(Context, i, NewAttr);
}
}
@@ -4125,12 +4124,13 @@ Error BitcodeReader::propagateAttributeTypes(CallBase *CB,
if (!CI.hasArg())
continue;
- if (CI.isIndirect && !CB->getParamElementType(ArgNo)) {
+ if (CI.isIndirect && !Attrs.getParamElementType(ArgNo)) {
Type *ElemTy = getPtrElementTypeByID(ArgTyIDs[ArgNo]);
if (!ElemTy)
return error("Missing element type for inline asm upgrade");
- CB->addParamAttr(
- ArgNo, Attribute::get(Context, Attribute::ElementType, ElemTy));
+ Attrs = Attrs.addParamAttribute(
+ Context, ArgNo,
+ Attribute::get(Context, Attribute::ElementType, ElemTy));
}
ArgNo++;
@@ -4140,18 +4140,19 @@ Error BitcodeReader::propagateAttributeTypes(CallBase *CB,
switch (CB->getIntrinsicID()) {
case Intrinsic::preserve_array_access_index:
case Intrinsic::preserve_struct_access_index:
- if (!CB->getParamElementType(0)) {
+ if (!Attrs.getParamElementType(0)) {
Type *ElTy = getPtrElementTypeByID(ArgTyIDs[0]);
if (!ElTy)
return error("Missing element type for elementtype upgrade");
Attribute NewAttr = Attribute::get(Context, Attribute::ElementType, ElTy);
- CB->addParamAttr(0, NewAttr);
+ Attrs = Attrs.addParamAttribute(Context, 0, NewAttr);
}
break;
default:
break;
}
+ CB->setAttributes(Attrs);
return Error::success();
}