[PATCH] D115417: [LTO] Fix incomplete optimization remarks when PreOptModuleHook or PostInternalizeModuleHook is defined
Xu Mingjie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 10 01:15:14 PST 2021
Enna1 added a comment.
In https://reviews.llvm.org/D46376, we add support for optimization remarks to ThinLTO Backend, we call `finalizeOptimizationRemarks()` when PreOptModuleHook, PostPromoteModuleHook, PostInternalizeModuleHook, PostImportModuleHook is defined.
This patch call `finalizeOptimizationRemarks()` when PreOptModuleHook or PostInternalizeModuleHook is defined for Regular LTO Backend.
Cause `llvm-lto2` does not have an option to define PreOptModuleHook or PreOptModuleHook for Regular LTO Backend, it's hard to write a testcase.
We can reproduce this bug using the following testcase:
$ clang++ -c -flto tu1.cpp -o tu1.o
$ clang++ -c -flto tu2.cpp -o tu2.o
$ clang++ -fuse-ld=lld -flto -foptimization-record-passes=lto tu1.o tu2.o -Wl,--opt-remarks-filename,opt.lto.yaml -Wl,--plugin-opt=emit-llvm
The content of tu1.cpp and tu2.cpp:
// tu1.cpp
int unused(int a);
int probably_inlined(int a);
int main(int argc, const char *argv[]) {
return probably_inlined(argc);
}
// tu2.cpp
int unused(int a) {
return a + 1;
}
int probably_inlined(int a) {
return a + 2;
}
The content of `opt.lto.yaml` is empty or incomplete due to this bug.
If this patch is applied, the content of `opt.lto.yaml` will be:
--- !Passed
Pass: lto
Name: deadfunction
Function: _Z6unusedi
Args:
- Function: _Z6unusedi
- String: ' not added to the combined module '
...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115417/new/
https://reviews.llvm.org/D115417
More information about the llvm-commits
mailing list