[Remarks][2/2] Expand remarks hotness threshold option support in more tools
authorWei Wang <apollo.mobility@gmail.com>
Tue, 17 Nov 2020 18:43:02 +0000 (10:43 -0800)
committerWei Wang <apollo.mobility@gmail.com>
Tue, 1 Dec 2020 05:55:50 +0000 (21:55 -0800)
commit93dc1b5b8cb2f85d0d347f39e49a7150accd4e70
treef9e980350d54670506474da4db31a635f32d3992
parent3acda91742b7e995af87f1afaca5e0fa78669819
[Remarks][2/2] Expand remarks hotness threshold option support in more tools

This is the #2 of 2 changes that make remarks hotness threshold option
available in more tools. The changes also allow the threshold to sync with
hotness threshold from profile summary with special value 'auto'.

This change expands remarks hotness threshold option
-fdiagnostics-hotness-threshold in clang and *-remarks-hotness-threshold in
other tools to utilize hotness threshold from profile summary.

Remarks hotness filtering relies on several driver options. Table below lists
how different options are correlated and affect final remarks outputs:

| profile | hotness | threshold | remarks printed |
|---------|---------|-----------|-----------------|
| No      | No      | No        | All             |
| No      | No      | Yes       | None            |
| No      | Yes     | No        | All             |
| No      | Yes     | Yes       | None            |
| Yes     | No      | No        | All             |
| Yes     | No      | Yes       | None            |
| Yes     | Yes     | No        | All             |
| Yes     | Yes     | Yes       | >=threshold     |

In the presence of profile summary, it is often more desirable to directly use
the hotness threshold from profile summary. The new argument value 'auto'
indicates threshold will be synced with hotness threshold from profile summary
during compilation. The "auto" threshold relies on the availability of profile
summary. In case of missing such information, no remarks will be generated.

Differential Revision: https://reviews.llvm.org/D85808
18 files changed:
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/opt-record.c
clang/test/Frontend/Inputs/remarks-hotness.prof [new file with mode: 0644]
clang/test/Frontend/remarks-hotness.cpp [new file with mode: 0644]
llvm/include/llvm/Analysis/ProfileSummaryInfo.h
llvm/include/llvm/IR/LLVMContext.h
llvm/include/llvm/IR/Module.h
llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/IR/Module.cpp
llvm/test/Other/optimization-remarks-auto.ll [new file with mode: 0644]
llvm/test/Transforms/SampleProfile/Inputs/remarks-hotness.prof [new file with mode: 0644]
llvm/test/Transforms/SampleProfile/remarks-hotness.ll [new file with mode: 0644]