[llvm] 7c89581 - AMDGPU: Remove amdgpu-waves-per-eu support in old attribute pass

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 08:52:57 PDT 2023


Author: Matt Arsenault
Date: 2023-06-19T11:50:50-04:00
New Revision: 7c8958118c6f695b01c98db6984390d2ee4fdb1a

URL: https://github.com/llvm/llvm-project/commit/7c8958118c6f695b01c98db6984390d2ee4fdb1a
DIFF: https://github.com/llvm/llvm-project/commit/7c8958118c6f695b01c98db6984390d2ee4fdb1a.diff

LOG: AMDGPU: Remove amdgpu-waves-per-eu support in old attribute pass

AMDGPUAttributor now handles this attribute with value merging, so
delete the old approach which could only apply this to functions which
did not set it, or cloned the function.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
    llvm/test/CodeGen/AMDGPU/propagate-attributes-clone.ll
    llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
index 5a4ab467731ec..f256fd9493aec 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
@@ -53,12 +53,6 @@ static constexpr const FeatureBitset TargetFeatures = {
   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 @@ class AMDGPUPropagateAttributes {
   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<Attribute> Attributes[NumAttr];
   };
 
   class Clone {
@@ -126,10 +110,6 @@ class AMDGPUPropagateAttributes {
   // 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<std::optional<Attribute>> NewAttrs);
-
   std::string getFeatureString(const FeatureBitset &Features) const;
 
   // Propagate attributes from Roots.
@@ -274,7 +254,6 @@ bool AMDGPUPropagateAttributes::process() {
             // 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 @@ AMDGPUPropagateAttributes::cloneWithProperties(Function &F,
   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 @@ void AMDGPUPropagateAttributes::setFeatures(Function &F,
   F.addFnAttr("target-features", NewFeatureStr);
 }
 
-void AMDGPUPropagateAttributes::setAttributes(
-    Function &F, const ArrayRef<std::optional<Attribute>> 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
 {

diff  --git a/llvm/test/CodeGen/AMDGPU/propagate-attributes-clone.ll b/llvm/test/CodeGen/AMDGPU/propagate-attributes-clone.ll
index 461a2b90ea410..e5b992449b222 100644
--- a/llvm/test/CodeGen/AMDGPU/propagate-attributes-clone.ll
+++ b/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 @@ entry:
   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" }

diff  --git a/llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll b/llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll
index 1584888c75a12..fa0cdc8d37d14 100644
--- a/llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll
+++ b/llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll
@@ -37,4 +37,4 @@ define private void @g() #1 {
 }
 
 attributes #0 = { noinline }
-attributes #1 = { noinline "amdgpu-waves-per-eu"="1,10" }
+attributes #1 = { noinline "target-features"="+wavefrontsize32" }


        


More information about the llvm-commits mailing list