[llvm] r314874 - Move verbosity check for remarks to the diag handler

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 21:26:23 PDT 2017


Author: anemet
Date: Tue Oct  3 21:26:23 2017
New Revision: 314874

URL: http://llvm.org/viewvc/llvm-project?rev=314874&view=rev
Log:
Move verbosity check for remarks to the diag handler

Test needs some slight adjustment because we no longer check the existence of
BFI but rather that the actual hotness is set on the remark.  If entry_count
is not set getBlockProfileCount returns None.

Modified:
    llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp
    llvm/trunk/lib/IR/LLVMContext.cpp
    llvm/trunk/test/Transforms/Inline/optimization-remarks.ll

Modified: llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp?rev=314874&r1=314873&r2=314874&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp Tue Oct  3 21:26:23 2017
@@ -169,10 +169,7 @@ void OptimizationRemarkEmitter::emit(
     auto *P = &OptDiagBase;
     *Out << P;
   }
-  // FIXME: now that IsVerbose is part of DI, filtering for this will be moved
-  // from here to clang.
-  if (!OptDiag.isVerbose() || shouldEmitVerbose())
-    F->getContext().diagnose(OptDiag);
+  F->getContext().diagnose(OptDiag);
 }
 
 OptimizationRemarkEmitterWrapperPass::OptimizationRemarkEmitterWrapperPass()

Modified: llvm/trunk/lib/IR/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=314874&r1=314873&r2=314874&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContext.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContext.cpp Tue Oct  3 21:26:23 2017
@@ -199,8 +199,12 @@ static bool isDiagnosticEnabled(const Di
   // pattern, passed via one of the -pass-remarks* flags, matches the name of
   // the pass that is emitting the diagnostic. If there is no match, ignore the
   // diagnostic and return.
+  //
+  // Also noisy remarks are only enabled if we have hotness information to sort
+  // them.
   if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI))
-    return Remark->isEnabled();
+    return Remark->isEnabled() &&
+           (!Remark->isVerbose() || Remark->getHotness());
 
   return true;
 }

Modified: llvm/trunk/test/Transforms/Inline/optimization-remarks.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/optimization-remarks.ll?rev=314874&r1=314873&r2=314874&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/optimization-remarks.ll (original)
+++ llvm/trunk/test/Transforms/Inline/optimization-remarks.ll Tue Oct  3 21:26:23 2017
@@ -20,7 +20,7 @@
 ; CHECK: foz not inlined into bar because it should never be inlined (cost=never)
 
 ; Function Attrs: alwaysinline nounwind uwtable
-define i32 @foo(i32 %x, i32 %y) #0 {
+define i32 @foo(i32 %x, i32 %y) #0 !prof !1 {
 entry:
   %x.addr = alloca i32, align 4
   %y.addr = alloca i32, align 4
@@ -33,7 +33,7 @@ entry:
 }
 
 ; Function Attrs: noinline nounwind uwtable
-define float @foz(i32 %x, i32 %y) #1 {
+define float @foz(i32 %x, i32 %y) #1 !prof !1 {
 entry:
   %x.addr = alloca i32, align 4
   %y.addr = alloca i32, align 4
@@ -49,7 +49,7 @@ entry:
 declare i32 @fox()
 
 ; Function Attrs: nounwind uwtable
-define i32 @bar(i32 %j) #2 {
+define i32 @bar(i32 %j) #2 !prof !1 {
 entry:
   %j.addr = alloca i32, align 4
   store i32 %j, i32* %j.addr, align 4
@@ -76,3 +76,4 @@ attributes #2 = { nounwind uwtable "less
 !llvm.ident = !{!0}
 
 !0 = !{!"clang version 3.5.0 "}
+!1 = !{!"function_entry_count", i64 10}




More information about the llvm-commits mailing list