Index: llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp @@ -53,12 +53,6 @@ AMDGPU::FeatureWavefrontSize64 }; -// Attributes to propagate. -// TODO: Support conservative min/max merging instead of cloning. -static constexpr const char *AttributeNames[] = {"amdgpu-waves-per-eu"}; - -static constexpr unsigned NumAttr = std::size(AttributeNames); - class AMDGPUPropagateAttributes { class FnProperties { @@ -68,30 +62,20 @@ public: explicit FnProperties(const TargetMachine &TM, const Function &F) { Features = TM.getSubtargetImpl(F)->getFeatureBits(); - - for (unsigned I = 0; I < NumAttr; ++I) - if (F.hasFnAttribute(AttributeNames[I])) - Attributes[I] = F.getFnAttribute(AttributeNames[I]); } bool operator == (const FnProperties &Other) const { if ((Features & TargetFeatures) != (Other.Features & TargetFeatures)) return false; - for (unsigned I = 0; I < NumAttr; ++I) - if (Attributes[I] != Other.Attributes[I]) - return false; return true; } FnProperties adjustToCaller(const FnProperties &CallerProps) const { FnProperties New((Features & ~TargetFeatures) | CallerProps.Features); - for (unsigned I = 0; I < NumAttr; ++I) - New.Attributes[I] = CallerProps.Attributes[I]; return New; } FeatureBitset Features; - std::optional Attributes[NumAttr]; }; class Clone { @@ -126,10 +110,6 @@ // Set new function's features in place. void setFeatures(Function &F, const FeatureBitset &NewFeatures); - // Set new function's attributes in place. - void setAttributes(Function &F, - const ArrayRef> NewAttrs); - std::string getFeatureString(const FeatureBitset &Features) const; // Propagate attributes from Roots. @@ -274,7 +254,6 @@ // we rely on a second pass running on Module, which is allowed // to clone. setFeatures(F, NewProps.Features); - setAttributes(F, NewProps.Attributes); NewRoots.insert(&F); Changed = true; break; @@ -317,7 +296,6 @@ ValueToValueMapTy dummy; Function *NewF = CloneFunction(&F, dummy); setFeatures(*NewF, NewProps.Features); - setAttributes(*NewF, NewProps.Attributes); NewF->setVisibility(GlobalValue::DefaultVisibility); NewF->setLinkage(GlobalValue::InternalLinkage); @@ -344,18 +322,6 @@ F.addFnAttr("target-features", NewFeatureStr); } -void AMDGPUPropagateAttributes::setAttributes( - Function &F, const ArrayRef> NewAttrs) { - LLVM_DEBUG(dbgs() << "Set attributes on " << F.getName() << ":\n"); - for (unsigned I = 0; I < NumAttr; ++I) { - F.removeFnAttr(AttributeNames[I]); - if (NewAttrs[I]) { - LLVM_DEBUG(dbgs() << '\t' << NewAttrs[I]->getAsString() << '\n'); - F.addFnAttr(*NewAttrs[I]); - } - } -} - std::string AMDGPUPropagateAttributes::getFeatureString(const FeatureBitset &Features) const { Index: llvm/test/CodeGen/AMDGPU/propagate-attributes-clone.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/propagate-attributes-clone.ll +++ llvm/test/CodeGen/AMDGPU/propagate-attributes-clone.ll @@ -58,11 +58,11 @@ ; OPT-INT: define internal fastcc void @foo3() unnamed_addr #4 ; OPT-EXT: define internal fastcc void @foo2.3() unnamed_addr #4 ; OPT-INT: define internal fastcc void @foo2() unnamed_addr #4 -; OPT: attributes #0 = { {{.*}} "amdgpu-waves-per-eu"="1,1" "target-features"="+wavefrontsize64" } +; OPT: attributes #0 = { {{.*}} "target-features"="+wavefrontsize64" } ; OPT: attributes #1 = { {{.*}} "target-features"="{{.*}},-wavefrontsize16,-wavefrontsize32,+wavefrontsize64{{.*}}" } -; OPT: attributes #2 = { {{.*}} "amdgpu-waves-per-eu"="2,4" "target-features"="+wavefrontsize32" } +; OPT: attributes #2 = { {{.*}} "target-features"="+wavefrontsize32" } ; OPT: attributes #3 = { {{.*}} "target-features"="+wavefrontsize64" } -; OPT: attributes #4 = { {{.*}} "amdgpu-waves-per-eu"="2,4" "target-features"="{{.*}},-wavefrontsize16,+wavefrontsize32,-wavefrontsize64{{.*}}" } +; OPT: attributes #4 = { {{.*}} "target-features"="{{.*}},-wavefrontsize16,+wavefrontsize32,-wavefrontsize64{{.*}}" } ; LLC: foo3: ; LLC: sample asm @@ -138,8 +138,8 @@ ret void } -attributes #0 = { nounwind "target-features"="+wavefrontsize32" "amdgpu-waves-per-eu"="2,4" } -attributes #1 = { noinline nounwind "target-features"="+wavefrontsize64" "amdgpu-waves-per-eu"="1,1" } +attributes #0 = { nounwind "target-features"="+wavefrontsize32" } +attributes #1 = { noinline nounwind "target-features"="+wavefrontsize64" } attributes #2 = { nounwind "target-features"="+wavefrontsize64" } attributes #3 = { nounwind "target-features"="+wavefrontsize64" } -attributes #4 = { noinline nounwind "target-features"="+wavefrontsize64" "amdgpu-waves-per-eu"="2,4" } +attributes #4 = { noinline nounwind "target-features"="+wavefrontsize64" } Index: llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll +++ llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll @@ -37,4 +37,4 @@ } attributes #0 = { noinline } -attributes #1 = { noinline "amdgpu-waves-per-eu"="1,10" } +attributes #1 = { noinline "target-features"="+wavefrontsize32" }