Skip to content

Commit

Permalink
[Autobackout][FunctionalRegression]Revert of change: 80ed233: Tweakin…
Browse files Browse the repository at this point in the history
…g 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.
  • Loading branch information
sys-igc authored and igcbot committed Jan 31, 2025
1 parent f7834d3 commit b859709
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
28 changes: 17 additions & 11 deletions IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,13 @@ Value* PromoteBools::getOrCreatePromotedValue(Value* value)
return newValue;
}

template<typename T>
void PromoteBools::setPromotedAttributes(T* newCallOrFunc, const AttributeList& attributeList)
void PromoteBools::setPromotedAttributes(Function* newFunction, AttributeList& attributeList)
{
auto getPromoted = [this, &newCallOrFunc](llvm::Attribute attr)
auto getPromoted = [this, &newFunction](llvm::Attribute attr)
{
if (attr.isTypeAttribute())
{
return attr.getWithNewType(newCallOrFunc->getContext(),
return attr.getWithNewType(newFunction->getContext(),
getOrCreatePromotedType(attr.getValueAsType()));
}
else
Expand All @@ -547,28 +546,35 @@ void PromoteBools::setPromotedAttributes(T* newCallOrFunc, const AttributeList&
};

// set function attributes
AttrBuilder attrBuilder(newFunction->getContext());
for (const auto& attr : attributeList.getFnAttrs())
{
newCallOrFunc->addFnAttr(getPromoted(attr));
attrBuilder.addAttribute(getPromoted(attr));
}
newFunction->addFnAttrs(attrBuilder);

for (const auto& attr : attributeList.getRetAttrs())
// set return attributes
attrBuilder.clear();
for (const auto &attr : attributeList.getRetAttrs())
{
newCallOrFunc->addRetAttr(getPromoted(attr));
attrBuilder.addAttribute(getPromoted(attr));
}
newFunction->addRetAttrs(attrBuilder);

// set params' attributes
for (size_t i = 0; i < newCallOrFunc->arg_size(); i++)
for (size_t i = 0; i < newFunction->arg_size(); i++)
{
if (!attributeList.hasParamAttrs(i))
{
continue;
}

attrBuilder.clear();
for (const auto& attr : attributeList.getParamAttrs(i))
{
newCallOrFunc->addParamAttr(i, getPromoted(attr));
attrBuilder.addAttribute(getPromoted(attr));
}
newFunction->addParamAttrs(i, attrBuilder);
}
}

Expand Down Expand Up @@ -889,7 +895,7 @@ CallInst* PromoteBools::promoteIndirectCallOrInlineAsm(CallInst* call)
call
);
newCall->setCallingConv(call->getCallingConv());
setPromotedAttributes(newCall, call->getAttributes());
newCall->setAttributes(call->getAttributes());
newCall->setDebugLoc(call->getDebugLoc());
return newCall;
}
Expand Down Expand Up @@ -962,7 +968,7 @@ CallInst* PromoteBools::promoteCall(CallInst* call)
call
);
newCall->setCallingConv(call->getCallingConv());
setPromotedAttributes(newCall, call->getAttributes());
newCall->setAttributes(call->getAttributes());
newCall->setDebugLoc(call->getDebugLoc());
return newCall;
}
Expand Down
3 changes: 1 addition & 2 deletions IGC/AdaptorOCL/preprocess_spvir/PromoteBools.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ namespace IGC
});
}

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

llvm::Value* getOrCreatePromotedValue(llvm::Value* value);
llvm::Function* promoteFunction(llvm::Function* function);
Expand Down
6 changes: 0 additions & 6 deletions IGC/Compiler/tests/PromoteBools/promote_attrs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@

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

define spir_func void @entry() {
%a = alloca %struct, align 8
call void @prom_attr(%struct* byval(%struct) align 8 %a)
ret void
}

define spir_func void @prom_attr(%struct* byval(%struct) align 8 %0) {
ret void
}

0 comments on commit b859709

Please sign in to comment.