[clang] f686e4b - [Remarks] Make sure -fdiagnostics-hotness-threshold implies -fdiagnostics-show-hotness

via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 26 04:49:01 PDT 2023


Author: serge-sans-paille
Date: 2023-06-26T13:48:10+02:00
New Revision: f686e4bbc20a837ff5230656431aec1abbd5f872

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

LOG: [Remarks] Make sure -fdiagnostics-hotness-threshold implies -fdiagnostics-show-hotness

When asking for -fdiagnostics-hotness-threshold, we currently require
-fdiagnostics-show-hotness otherwise we silently display nothing.

I don't see a scenario where that makes sense, so have one option impy
the other.

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

Added: 
    

Modified: 
    clang/test/Frontend/remarks-hotness.cpp
    llvm/lib/IR/LLVMRemarkStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/Frontend/remarks-hotness.cpp b/clang/test/Frontend/remarks-hotness.cpp
index 72753d014ff2f..a9eb289586eb2 100644
--- a/clang/test/Frontend/remarks-hotness.cpp
+++ b/clang/test/Frontend/remarks-hotness.cpp
@@ -13,6 +13,13 @@
 // RUN:     -fdiagnostics-hotness-threshold=auto 2>&1 \
 // RUN:     | FileCheck -check-prefix=HOT_CALL %s
 
+// Make sure -fdiagnostics-hotness-threshold implies -fdiagnostics-show-hotness
+// RUN: %clang_cc1 -triple x86_64-linux %s -emit-llvm-only -O3 \
+// RUN:     -fprofile-sample-use=%S/Inputs/remarks-hotness.prof \
+// RUN:     -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline \
+// RUN:     -fdiagnostics-hotness-threshold=auto 2>&1 \
+// RUN:     | FileCheck -check-prefix=HOT_CALL %s
+
 int callee1() {
   return 1;
 }

diff  --git a/llvm/lib/IR/LLVMRemarkStreamer.cpp b/llvm/lib/IR/LLVMRemarkStreamer.cpp
index 8fbc33328de82..71f8d4a4b1c7c 100644
--- a/llvm/lib/IR/LLVMRemarkStreamer.cpp
+++ b/llvm/lib/IR/LLVMRemarkStreamer.cpp
@@ -96,8 +96,8 @@ Expected<std::unique_ptr<ToolOutputFile>> llvm::setupLLVMOptimizationRemarks(
     LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses,
     StringRef RemarksFormat, bool RemarksWithHotness,
     std::optional<uint64_t> RemarksHotnessThreshold) {
-  if (RemarksWithHotness)
-    Context.setDiagnosticsHotnessRequested(true);
+  if (RemarksWithHotness || RemarksHotnessThreshold.value_or(1))
+      Context.setDiagnosticsHotnessRequested(true);
 
   Context.setDiagnosticsHotnessThreshold(RemarksHotnessThreshold);
 
@@ -143,7 +143,7 @@ Error llvm::setupLLVMOptimizationRemarks(
     LLVMContext &Context, raw_ostream &OS, StringRef RemarksPasses,
     StringRef RemarksFormat, bool RemarksWithHotness,
     std::optional<uint64_t> RemarksHotnessThreshold) {
-  if (RemarksWithHotness)
+  if (RemarksWithHotness || RemarksHotnessThreshold.value_or(1))
     Context.setDiagnosticsHotnessRequested(true);
 
   Context.setDiagnosticsHotnessThreshold(RemarksHotnessThreshold);


        


More information about the cfe-commits mailing list