From b8597091869a4929b8bf9953f5df0e7d5a1d1ab3 Mon Sep 17 00:00:00 2001 From: sys_igc Date: Fri, 31 Jan 2025 04:17:29 +0100 Subject: [PATCH] [Autobackout][FunctionalRegression]Revert of change: 80ed2332cff0c9f22c737be79ad8cb858a9f3433: 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. --- .../preprocess_spvir/PromoteBools.cpp | 28 +++++++++++-------- .../preprocess_spvir/PromoteBools.h | 3 +- .../tests/PromoteBools/promote_attrs.ll | 6 ---- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp b/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp index 76b9845d8d49..c458d54db73d 100644 --- a/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp +++ b/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp @@ -530,14 +530,13 @@ Value* PromoteBools::getOrCreatePromotedValue(Value* value) return newValue; } -template -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 @@ -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); } } @@ -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; } @@ -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; } diff --git a/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.h b/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.h index 6056e6d5ec14..d24b4e1f3731 100644 --- a/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.h +++ b/IGC/AdaptorOCL/preprocess_spvir/PromoteBools.h @@ -77,8 +77,7 @@ namespace IGC }); } - template - 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); diff --git a/IGC/Compiler/tests/PromoteBools/promote_attrs.ll b/IGC/Compiler/tests/PromoteBools/promote_attrs.ll index 30df2f5117d2..debcec3fb06c 100644 --- a/IGC/Compiler/tests/PromoteBools/promote_attrs.ll +++ b/IGC/Compiler/tests/PromoteBools/promote_attrs.ll @@ -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 }