Skip to content

Commit b859709

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 80ed233: Tweaking types held in attribute lists of call instructions
This change is to attach correct attribute lists to new call instructions in `PromoteBools`. The attribute list must contain promoted types to be in sync with their called function.
1 parent f7834d3 commit b859709

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,13 @@ Value* PromoteBools::getOrCreatePromotedValue(Value* value)
530530
return newValue;
531531
}
532532

533-
template<typename T>
534-
void PromoteBools::setPromotedAttributes(T* newCallOrFunc, const AttributeList& attributeList)
533+
void PromoteBools::setPromotedAttributes(Function* newFunction, AttributeList& attributeList)
535534
{
536-
auto getPromoted = [this, &newCallOrFunc](llvm::Attribute attr)
535+
auto getPromoted = [this, &newFunction](llvm::Attribute attr)
537536
{
538537
if (attr.isTypeAttribute())
539538
{
540-
return attr.getWithNewType(newCallOrFunc->getContext(),
539+
return attr.getWithNewType(newFunction->getContext(),
541540
getOrCreatePromotedType(attr.getValueAsType()));
542541
}
543542
else
@@ -547,28 +546,35 @@ void PromoteBools::setPromotedAttributes(T* newCallOrFunc, const AttributeList&
547546
};
548547

549548
// set function attributes
549+
AttrBuilder attrBuilder(newFunction->getContext());
550550
for (const auto& attr : attributeList.getFnAttrs())
551551
{
552-
newCallOrFunc->addFnAttr(getPromoted(attr));
552+
attrBuilder.addAttribute(getPromoted(attr));
553553
}
554+
newFunction->addFnAttrs(attrBuilder);
554555

555-
for (const auto& attr : attributeList.getRetAttrs())
556+
// set return attributes
557+
attrBuilder.clear();
558+
for (const auto &attr : attributeList.getRetAttrs())
556559
{
557-
newCallOrFunc->addRetAttr(getPromoted(attr));
560+
attrBuilder.addAttribute(getPromoted(attr));
558561
}
562+
newFunction->addRetAttrs(attrBuilder);
559563

560564
// 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++)
562566
{
563567
if (!attributeList.hasParamAttrs(i))
564568
{
565569
continue;
566570
}
567571

572+
attrBuilder.clear();
568573
for (const auto& attr : attributeList.getParamAttrs(i))
569574
{
570-
newCallOrFunc->addParamAttr(i, getPromoted(attr));
575+
attrBuilder.addAttribute(getPromoted(attr));
571576
}
577+
newFunction->addParamAttrs(i, attrBuilder);
572578
}
573579
}
574580

@@ -889,7 +895,7 @@ CallInst* PromoteBools::promoteIndirectCallOrInlineAsm(CallInst* call)
889895
call
890896
);
891897
newCall->setCallingConv(call->getCallingConv());
892-
setPromotedAttributes(newCall, call->getAttributes());
898+
newCall->setAttributes(call->getAttributes());
893899
newCall->setDebugLoc(call->getDebugLoc());
894900
return newCall;
895901
}
@@ -962,7 +968,7 @@ CallInst* PromoteBools::promoteCall(CallInst* call)
962968
call
963969
);
964970
newCall->setCallingConv(call->getCallingConv());
965-
setPromotedAttributes(newCall, call->getAttributes());
971+
newCall->setAttributes(call->getAttributes());
966972
newCall->setDebugLoc(call->getDebugLoc());
967973
return newCall;
968974
}

IGC/AdaptorOCL/preprocess_spvir/PromoteBools.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ namespace IGC
7777
});
7878
}
7979

80-
template<typename T>
81-
void setPromotedAttributes(T* callOrFunc, const llvm::AttributeList& attributeList);
80+
void setPromotedAttributes(llvm::Function* newFunction, llvm::AttributeList& attributeList);
8281

8382
llvm::Value* getOrCreatePromotedValue(llvm::Value* value);
8483
llvm::Function* promoteFunction(llvm::Function* function);

IGC/Compiler/tests/PromoteBools/promote_attrs.ll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414

1515
%struct = type { [4 x <8 x i1*>], [4 x <8 x i1>*]* }
1616

17-
define spir_func void @entry() {
18-
%a = alloca %struct, align 8
19-
call void @prom_attr(%struct* byval(%struct) align 8 %a)
20-
ret void
21-
}
22-
2317
define spir_func void @prom_attr(%struct* byval(%struct) align 8 %0) {
2418
ret void
2519
}

0 commit comments

Comments
 (0)