[PATCH] D84246: [clang][LTO] Pass-through remarks options and set auto hotness threshold
Wei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 21 09:13:18 PDT 2020
weiwang created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dang, dexonsmith, steven_wu, MaskRay, hiraditya, eraman, arichardson, inglorion, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: MaskRay.
Herald added projects: clang, LLVM.
Expand remarks hotness threshold option -fdiagnostics-hotness-threshold in clang
driver command-line to both filtering remarks by hotness threshold from profile
summary and automatic remarks options pass-through to linker.
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 |
|
The new argument value -fdiagnostics-hotness-threshold=auto indicates threshold
will be synced with hotness threshold from profile summary during compilation.
In addition, when the following conditions are met, remarks related options are
passed into linker as well:
1. LTO is enabled;
2. Single arch target is specified;
3. The linker is lld;
The "auto" threshold relies on the availability of profile summary. In case of
missing such information, no remarks will be generated.
This gives novice user a convenient way to collect and filter remarks throughout
a typical toolchain invocation with sample profile and LTO using single switch
from the clang driver.
A typical use of this option from clang command-line:
- Using -Rpass* options to print remarks to screen:
clang -fuse-ld=lld -flto=thin
-fprofile-sample-use=foo_sample.txt
-Rpass=inline
-Rpass-missed=inline -Rpass-analysis=inline
-fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=auto
-o foo foo.cpp
Remarks will be dumped to screen from both pre-lto and lto compilation.
- Using serialized remarks options:
clang -fuse-ld=lld -flto=thin
-fprofile-sample-use=foo_sample.txt -fsave-optimization-record
-fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=auto
-o foo foo.cpp
This will produce multiple yaml files containing optimization remarks:
- foo.opt.yaml : remarks from pre-lto
- foo.opt.ld.yaml.thin.1.yaml: remark during lto
Both types of options can be used together.
Given its restricted use cases, this shouldn't be viewed as a complete
replacement of current remarks option handling for the linker.
In order to make the option consistent across various tools, the support for the
new 'auto' argument is also available in the following tools:
- lld: -opt-remarks-with-hotness=auto
- llvm-lto: -lto-pass-remarks-hotness-threshold=auto
- opt/llc: --pass-remarks-hotness-threshold=auto
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84246
Files:
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/remarks-pass-through.c
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/ELF/Options.td
lld/test/ELF/lto/opt-remarks.ll
llvm/include/llvm/Analysis/ProfileSummaryInfo.h
llvm/include/llvm/IR/LLVMContext.h
llvm/include/llvm/IR/LLVMRemarkStreamer.h
llvm/include/llvm/IR/Module.h
llvm/include/llvm/LTO/Config.h
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Remarks/HotnessThresholdParser.h
llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/IR/Module.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll
llvm/test/Other/optimization-remarks-auto.ll
llvm/test/Transforms/SampleProfile/Inputs/remarks-hotness.prof
llvm/test/Transforms/SampleProfile/remarks-hotness.ll
llvm/tools/llc/llc.cpp
llvm/tools/opt/opt.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84246.279552.patch
Type: text/x-patch
Size: 53028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200721/ede2f8e5/attachment.bin>
More information about the llvm-commits
mailing list