[llvm] 0ff02cf - [AMDGPU] Hide "removing function" diagnostics by default

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 00:26:26 PDT 2023


Author: pvanhout
Date: 2023-04-11T09:26:20+02:00
New Revision: 0ff02cf015d3e6bdf80e971355faf5e6b98bd9e9

URL: https://github.com/llvm/llvm-project/commit/0ff02cf015d3e6bdf80e971355faf5e6b98bd9e9
DIFF: https://github.com/llvm/llvm-project/commit/0ff02cf015d3e6bdf80e971355faf5e6b98bd9e9.diff

LOG: [AMDGPU] Hide "removing function" diagnostics by default

Use an `OptimizationRemark` for them even though it's not really an
optimization. It just integrates better with the other diagnostics
(enabling is easy with `-pass-remark`).

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D147703

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
    llvm/test/CodeGen/AMDGPU/remove-incompatible-functions.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp b/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
index c5ca2ef2b2490..ff43f4cb57e60 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
@@ -14,8 +14,7 @@
 
 #include "AMDGPU.h"
 #include "GCNSubtarget.h"
-#include "llvm/IR/DiagnosticInfo.h"
-#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/Module.h"
@@ -108,27 +107,6 @@ FeatureBitset expandImpliedFeatures(const FeatureBitset &Features) {
   }
   return Result;
 }
-
-static int DK_IncompatibleFn = getNextAvailablePluginDiagnosticKind();
-
-struct DiagnosticInfoRemovingIncompatibleFunction
-    : public DiagnosticInfoWithLocationBase {
-  DiagnosticInfoRemovingIncompatibleFunction(Function &F, Twine M)
-      : DiagnosticInfoWithLocationBase(DiagnosticKind(DK_IncompatibleFn),
-                                       DS_Remark, F, DiagnosticLocation()),
-        Msg(M.str()) {}
-
-  void print(DiagnosticPrinter &DP) const override {
-    DP << getFunction().getName() << ": removing function: " << Msg;
-  }
-
-  static bool classof(const DiagnosticInfo *DI) {
-    return DI->getKind() == DK_IncompatibleFn;
-  }
-
-  std::string Msg;
-};
-
 } // end anonymous namespace
 
 bool AMDGPURemoveIncompatibleFunctions::checkFunction(Function &F) {
@@ -150,8 +128,6 @@ bool AMDGPURemoveIncompatibleFunctions::checkFunction(Function &F) {
   if (!GPUInfo)
     return false;
 
-  LLVMContext &Ctx = F.getContext();
-
   // Get all the features implied by the current GPU, and recursively expand
   // the features that imply other features.
   //
@@ -167,10 +143,17 @@ bool AMDGPURemoveIncompatibleFunctions::checkFunction(Function &F) {
   // GPU's feature set. We only check a predetermined set of features.
   for (unsigned Feature : FeaturesToCheck) {
     if (ST->hasFeature(Feature) && !GPUFeatureBits.test(Feature)) {
-      DiagnosticInfoRemovingIncompatibleFunction DiagInfo(
-          F, "+" + getFeatureName(Feature) +
-                 " is not supported on the current target");
-      Ctx.diagnose(DiagInfo);
+      OptimizationRemarkEmitter ORE(&F);
+      ORE.emit([&]() {
+        // Note: we print the function name as part of the diagnostic because if
+        // debug info is not present, users get "<unknown>:0:0" as the debug
+        // loc. If we didn't print the function name there would be no way to
+        // tell which function got removed.
+        return OptimizationRemark(DEBUG_TYPE, "AMDGPUIncompatibleFnRemoved", &F)
+               << "removing function '" << F.getName() << "': +"
+               << getFeatureName(Feature)
+               << " is not supported on the current target";
+      });
       return true;
     }
   }

diff  --git a/llvm/test/CodeGen/AMDGPU/remove-incompatible-functions.ll b/llvm/test/CodeGen/AMDGPU/remove-incompatible-functions.ll
index 56fb98784392c..020e878173a69 100644
--- a/llvm/test/CodeGen/AMDGPU/remove-incompatible-functions.ll
+++ b/llvm/test/CodeGen/AMDGPU/remove-incompatible-functions.ll
@@ -1,89 +1,95 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -march=amdgcn -mcpu=bonaire -stop-after=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX7,IR %s
+; RUN: llc -march=amdgcn -mcpu=bonaire -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX7,IR %s
 ; RUN: FileCheck --check-prefix=WARN-GFX7 %s < %t
 ; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s
 
-; RUN: llc -march=amdgcn -mcpu=fiji -stop-after=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX8,IR %s
+; RUN: llc -march=amdgcn -mcpu=fiji -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX8,IR %s
 ; RUN: FileCheck --check-prefix=WARN-GFX8 %s < %t
 ; RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s
 
-; RUN: llc -march=amdgcn -mcpu=gfx906 -stop-after=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX9,GFX906,IR %s
+; RUN: llc -march=amdgcn -mcpu=gfx906 -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX9,GFX906,IR %s
 ; RUN: FileCheck --check-prefix=WARN-GFX906 %s < %t
 ; RUN: llc -march=amdgcn -mcpu=gfx906 -verify-machineinstrs < %s
 
-; RUN: llc -march=amdgcn -mcpu=gfx90a -stop-after=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX9,GFX90A,IR %s
+; RUN: llc -march=amdgcn -mcpu=gfx90a -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX9,GFX90A,IR %s
 ; RUN: FileCheck --check-prefix=WARN-GFX90A %s < %t
 ; RUN: llc -march=amdgcn -mcpu=gfx90a -verify-machineinstrs < %s
 
-; RUN: llc -march=amdgcn -mcpu=gfx1011 -stop-after=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX10,IR %s
+; RUN: llc -march=amdgcn -mcpu=gfx1011 -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX10,IR %s
 ; RUN: FileCheck --check-prefix=WARN-GFX10 %s < %t
 ; RUN: llc -march=amdgcn -mcpu=gfx1011 -verify-machineinstrs < %s
 
-; RUN: llc -march=amdgcn -mcpu=gfx1100 -stop-after=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX11,IR %s
+; RUN: llc -march=amdgcn -mcpu=gfx1100 -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions < %s 2>%t | FileCheck -check-prefixes=GFX11,IR %s
 ; RUN: FileCheck --check-prefix=WARN-GFX11 %s < %t
 ; RUN: llc -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s
 
 ; Note: This test checks the IR, but also has a run line to codegen the file just to check we
 ; do not crash when trying to select those functions.
 
-; WARN-GFX7: needs_dpp: removing function: +dpp is not supported on the current target
-; WARN-GFX7: needs_16bit_insts: removing function: +16-bit-insts is not supported on the current target
-; WARN-GFX7: needs_gfx8_insts: removing function: +gfx8-insts is not supported on the current target
-; WARN-GFX7: needs_gfx9_insts: removing function: +gfx9-insts is not supported on the current target
-; WARN-GFX7: needs_gfx10_insts: removing function: +gfx10-insts is not supported on the current target
-; WARN-GFX7: needs_gfx11_insts: removing function: +gfx11-insts is not supported on the current target
-; WARN-GFX7: needs_dot1_insts: removing function: +dot1-insts is not supported on the current target
-; WARN-GFX7: needs_dot2_insts: removing function: +dot2-insts is not supported on the current target
-; WARN-GFX7: needs_dot3_insts: removing function: +dot3-insts is not supported on the current target
-; WARN-GFX7: needs_dot4_insts: removing function: +dot4-insts is not supported on the current target
-; WARN-GFX7: needs_dot5_insts: removing function: +dot5-insts is not supported on the current target
-; WARN-GFX7: needs_dot6_insts: removing function: +dot6-insts is not supported on the current target
-; WARN-GFX7: needs_dot7_insts: removing function: +dot7-insts is not supported on the current target
-; WARN-GFX7: needs_dot8_insts: removing function: +dot8-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dpp': +dpp is not supported on the current target
+; WARN-GFX7: removing function 'needs_16bit_insts': +16-bit-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_gfx8_insts': +gfx8-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_gfx9_insts': +gfx9-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_gfx10_insts': +gfx10-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_gfx11_insts': +gfx11-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot1_insts': +dot1-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot2_insts': +dot2-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot3_insts': +dot3-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot4_insts': +dot4-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot5_insts': +dot5-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot6_insts': +dot6-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot7_insts': +dot7-insts is not supported on the current target
+; WARN-GFX7: removing function 'needs_dot8_insts': +dot8-insts is not supported on the current target
 ; WARN-GFX7-NOT: not supported
 
-; WARN-GFX8: needs_gfx9_insts: removing function: +gfx9-insts is not supported on the current target
-; WARN-GFX8: needs_gfx10_insts: removing function: +gfx10-insts is not supported on the current target
-; WARN-GFX8: needs_gfx11_insts: removing function: +gfx11-insts is not supported on the current target
-; WARN-GFX8: needs_dot1_insts: removing function: +dot1-insts is not supported on the current target
-; WARN-GFX8: needs_dot2_insts: removing function: +dot2-insts is not supported on the current target
-; WARN-GFX8: needs_dot3_insts: removing function: +dot3-insts is not supported on the current target
-; WARN-GFX8: needs_dot4_insts: removing function: +dot4-insts is not supported on the current target
-; WARN-GFX8: needs_dot5_insts: removing function: +dot5-insts is not supported on the current target
-; WARN-GFX8: needs_dot6_insts: removing function: +dot6-insts is not supported on the current target
-; WARN-GFX8: needs_dot7_insts: removing function: +dot7-insts is not supported on the current target
-; WARN-GFX8: needs_dot8_insts: removing function: +dot8-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_gfx9_insts': +gfx9-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_gfx10_insts': +gfx10-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_gfx11_insts': +gfx11-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot1_insts': +dot1-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot2_insts': +dot2-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot3_insts': +dot3-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot4_insts': +dot4-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot5_insts': +dot5-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot6_insts': +dot6-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot7_insts': +dot7-insts is not supported on the current target
+; WARN-GFX8: removing function 'needs_dot8_insts': +dot8-insts is not supported on the current target
 ; WARN-GFX8-NOT: not supported
 
-; WARN-GFX906: needs_gfx10_insts: removing function: +gfx10-insts is not supported on the current target
-; WARN-GFX906: needs_gfx11_insts: removing function: +gfx11-insts is not supported on the current target
-; WARN-GFX906: needs_dot3_insts: removing function: +dot3-insts is not supported on the current target
-; WARN-GFX906: needs_dot4_insts: removing function: +dot4-insts is not supported on the current target
-; WARN-GFX906: needs_dot5_insts: removing function: +dot5-insts is not supported on the current target
-; WARN-GFX906: needs_dot6_insts: removing function: +dot6-insts is not supported on the current target
-; WARN-GFX906: needs_dot8_insts: removing function: +dot8-insts is not supported on the current target
+; WARN-GFX906: removing function 'needs_gfx10_insts': +gfx10-insts is not supported on the current target
+; WARN-GFX906: removing function 'needs_gfx11_insts': +gfx11-insts is not supported on the current target
+; WARN-GFX906: removing function 'needs_dot3_insts': +dot3-insts is not supported on the current target
+; WARN-GFX906: removing function 'needs_dot4_insts': +dot4-insts is not supported on the current target
+; WARN-GFX906: removing function 'needs_dot5_insts': +dot5-insts is not supported on the current target
+; WARN-GFX906: removing function 'needs_dot6_insts': +dot6-insts is not supported on the current target
+; WARN-GFX906: removing function 'needs_dot8_insts': +dot8-insts is not supported on the current target
 ; WARN-GFX906-NOT: not supported
 
-; WARN-GFX90A: needs_gfx10_insts: removing function: +gfx10-insts is not supported on the current target
-; WARN-GFX90A: needs_gfx11_insts: removing function: +gfx11-insts is not supported on the current target
-; WARN-GFX90A: needs_dot8_insts: removing function: +dot8-insts is not supported on the current target
+; WARN-GFX90A: removing function 'needs_gfx10_insts': +gfx10-insts is not supported on the current target
+; WARN-GFX90A: removing function 'needs_gfx11_insts': +gfx11-insts is not supported on the current target
+; WARN-GFX90A: removing function 'needs_dot8_insts': +dot8-insts is not supported on the current target
 ; WARN-GFX90A-NOT: not supported
 
-; WARN-GFX10: needs_gfx11_insts: removing function: +gfx11-insts is not supported on the current target
-; WARN-GFX10: needs_dot3_insts: removing function: +dot3-insts is not supported on the current target
-; WARN-GFX10: needs_dot4_insts: removing function: +dot4-insts is not supported on the current target
-; WARN-GFX10: needs_dot8_insts: removing function: +dot8-insts is not supported on the current target
+; WARN-GFX10: removing function 'needs_gfx11_insts': +gfx11-insts is not supported on the current target
+; WARN-GFX10: removing function 'needs_dot3_insts': +dot3-insts is not supported on the current target
+; WARN-GFX10: removing function 'needs_dot4_insts': +dot4-insts is not supported on the current target
+; WARN-GFX10: removing function 'needs_dot8_insts': +dot8-insts is not supported on the current target
 ; WARN-GFX10-NOT: not supported
 
-; WARN-GFX11: needs_dot1_insts: removing function: +dot1-insts is not supported on the current target
-; WARN-GFX11: needs_dot2_insts: removing function: +dot2-insts is not supported on the current target
-; WARN-GFX11: needs_dot3_insts: removing function: +dot3-insts is not supported on the current target
-; WARN-GFX11: needs_dot4_insts: removing function: +dot4-insts is not supported on the current target
-; WARN-GFX11: needs_dot6_insts: removing function: +dot6-insts is not supported on the current target
+; WARN-GFX11: removing function 'needs_dot1_insts': +dot1-insts is not supported on the current target
+; WARN-GFX11: removing function 'needs_dot2_insts': +dot2-insts is not supported on the current target
+; WARN-GFX11: removing function 'needs_dot3_insts': +dot3-insts is not supported on the current target
+; WARN-GFX11: removing function 'needs_dot4_insts': +dot4-insts is not supported on the current target
+; WARN-GFX11: removing function 'needs_dot6_insts': +dot6-insts is not supported on the current target
 ; WARN-GFX11-NOT: not supported
 
 ; GFX7:   @GVRefs {{.*}} zeroinitializer
-; GFX8:   @GVRefs {{.*}} [ptr @needs_dpp, ptr @needs_16bit_insts, ptr @needs_gfx8_insts, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null] 
+; GFX8:   @GVRefs {{.*}} [ptr @needs_dpp, ptr @needs_16bit_insts, ptr @needs_gfx8_insts, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null, ptr null]
 ; GFX906: @GVRefs {{.*}} [ptr @needs_dpp, ptr @needs_16bit_insts, ptr @needs_gfx8_insts, ptr @needs_gfx9_insts, ptr null, ptr null, ptr @needs_dot1_insts, ptr @needs_dot2_insts, ptr null, ptr null, ptr null, ptr null, ptr @needs_dot7_insts, ptr null]
 ; GFX90A: @GVRefs {{.*}} [ptr @needs_dpp, ptr @needs_16bit_insts, ptr @needs_gfx8_insts, ptr @needs_gfx9_insts, ptr null, ptr null, ptr @needs_dot1_insts, ptr @needs_dot2_insts, ptr @needs_dot3_insts, ptr @needs_dot4_insts, ptr @needs_dot5_insts, ptr @needs_dot6_insts, ptr @needs_dot7_insts, ptr null]
 ; GFX10:  @GVRefs {{.*}} [ptr @needs_dpp, ptr @needs_16bit_insts, ptr @needs_gfx8_insts, ptr @needs_gfx9_insts, ptr @needs_gfx10_insts, ptr null, ptr @needs_dot1_insts, ptr @needs_dot2_insts, ptr null, ptr null, ptr @needs_dot5_insts, ptr @needs_dot6_insts, ptr @needs_dot7_insts, ptr null]


        


More information about the llvm-commits mailing list