[PATCH] D62627: [NFC] Do not run CGProfilePass when -fno-integrated-as is on
Zhizhou Yang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 13:56:39 PDT 2019
zhizhouy created this revision.
zhizhouy added reviewers: Bigcheese, xur, george.burgess.iv.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.
CGProfilePass is run by default in certain new pass manager optimization pipeline. Assemblers other than llvm-as (such as gnu-as) cannot recognize the .cgprofile entries generated and emitted from this pass, causing build time error.
This patch adds a new opt option "enable-call-graph-profile-sort" (on by default) and we turn it off when "-fno-integrated-as" is specified in clang.
Since CGProfilePass only exists in new pass manager, it's a bit awkward that we will pass a nop -mllvm option if legacy pass manager is used.
-DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER when building LLVM will be a good solution to make this consistent.
Further opinions are welcome.
Repository:
rL LLVM
https://reviews.llvm.org/D62627
Files:
clang/lib/Driver/ToolChains/Clang.cpp
llvm/lib/Passes/PassBuilder.cpp
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -212,6 +212,10 @@
EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden,
cl::desc("Enable control height reduction optimization (CHR)"));
+static cl::opt<bool> EnableCallGraphProfileSort(
+ "enable-call-graph-profile-sort", cl::init(true), cl::Hidden,
+ cl::desc("Enable call graph profile pass for the new PM (default = on)"));
+
extern cl::opt<bool> EnableHotColdSplit;
extern cl::opt<bool> EnableOrderFileInstrumentation;
@@ -939,7 +943,8 @@
// Add the core optimizing pipeline.
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
- MPM.addPass(CGProfilePass());
+ if (EnableCallGraphProfileSort)
+ MPM.addPass(CGProfilePass());
// Now we need to do some global optimization transforms.
// FIXME: It would seem like these should come first in the optimization
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3995,8 +3995,13 @@
Args.hasArg(options::OPT_dA))
CmdArgs.push_back("-masm-verbose");
- if (!TC.useIntegratedAs())
+ if (!TC.useIntegratedAs()) {
CmdArgs.push_back("-no-integrated-as");
+ // .cgprofile can only be parsed by llvm-as, do not run CGProfilePass if
+ // integrated-as is not used.
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-enable-call-graph-profile-sort=false");
+ }
if (Args.hasArg(options::OPT_fdebug_pass_structure)) {
CmdArgs.push_back("-mdebug-pass");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62627.202048.patch
Type: text/x-patch
Size: 1742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190529/4a83a2c0/attachment.bin>
More information about the llvm-commits
mailing list