@@ -530,14 +530,13 @@ Value* PromoteBools::getOrCreatePromotedValue(Value* value)
530
530
return newValue;
531
531
}
532
532
533
- template <typename T>
534
- void PromoteBools::setPromotedAttributes (T* newCallOrFunc, const AttributeList& attributeList)
533
+ void PromoteBools::setPromotedAttributes (Function* newFunction, AttributeList& attributeList)
535
534
{
536
- auto getPromoted = [this , &newCallOrFunc ](llvm::Attribute attr)
535
+ auto getPromoted = [this , &newFunction ](llvm::Attribute attr)
537
536
{
538
537
if (attr.isTypeAttribute ())
539
538
{
540
- return attr.getWithNewType (newCallOrFunc ->getContext (),
539
+ return attr.getWithNewType (newFunction ->getContext (),
541
540
getOrCreatePromotedType (attr.getValueAsType ()));
542
541
}
543
542
else
@@ -547,28 +546,35 @@ void PromoteBools::setPromotedAttributes(T* newCallOrFunc, const AttributeList&
547
546
};
548
547
549
548
// set function attributes
549
+ AttrBuilder attrBuilder (newFunction->getContext ());
550
550
for (const auto & attr : attributeList.getFnAttrs ())
551
551
{
552
- newCallOrFunc-> addFnAttr (getPromoted (attr));
552
+ attrBuilder. addAttribute (getPromoted (attr));
553
553
}
554
+ newFunction->addFnAttrs (attrBuilder);
554
555
555
- for (const auto & attr : attributeList.getRetAttrs ())
556
+ // set return attributes
557
+ attrBuilder.clear ();
558
+ for (const auto &attr : attributeList.getRetAttrs ())
556
559
{
557
- newCallOrFunc-> addRetAttr (getPromoted (attr));
560
+ attrBuilder. addAttribute (getPromoted (attr));
558
561
}
562
+ newFunction->addRetAttrs (attrBuilder);
559
563
560
564
// set params' attributes
561
- for (size_t i = 0 ; i < newCallOrFunc ->arg_size (); i++)
565
+ for (size_t i = 0 ; i < newFunction ->arg_size (); i++)
562
566
{
563
567
if (!attributeList.hasParamAttrs (i))
564
568
{
565
569
continue ;
566
570
}
567
571
572
+ attrBuilder.clear ();
568
573
for (const auto & attr : attributeList.getParamAttrs (i))
569
574
{
570
- newCallOrFunc-> addParamAttr (i, getPromoted (attr));
575
+ attrBuilder. addAttribute ( getPromoted (attr));
571
576
}
577
+ newFunction->addParamAttrs (i, attrBuilder);
572
578
}
573
579
}
574
580
@@ -889,7 +895,7 @@ CallInst* PromoteBools::promoteIndirectCallOrInlineAsm(CallInst* call)
889
895
call
890
896
);
891
897
newCall->setCallingConv (call->getCallingConv ());
892
- setPromotedAttributes ( newCall, call->getAttributes ());
898
+ newCall-> setAttributes ( call->getAttributes ());
893
899
newCall->setDebugLoc (call->getDebugLoc ());
894
900
return newCall;
895
901
}
@@ -962,7 +968,7 @@ CallInst* PromoteBools::promoteCall(CallInst* call)
962
968
call
963
969
);
964
970
newCall->setCallingConv (call->getCallingConv ());
965
- setPromotedAttributes ( newCall, call->getAttributes ());
971
+ newCall-> setAttributes ( call->getAttributes ());
966
972
newCall->setDebugLoc (call->getDebugLoc ());
967
973
return newCall;
968
974
}
0 commit comments