[PATCH] D62627: [NFC] Do not run CGProfilePass when -fno-integrated-as is on

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 17:41:34 PDT 2019


chandlerc added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3999-4003
     CmdArgs.push_back("-no-integrated-as");
+    // .cgprofile can only be parsed by llvm MC assembler, do not run
+    // CGProfilePass if integrated-as is not used.
+    CmdArgs.push_back("-mllvm");
+    CmdArgs.push_back("-enable-npm-call-graph-profile=false");
----------------
the call garph profile stuff needs to be a Clang `CodeGenOpt` IMO. Then it can be used to set a bool in the pass builder's option struct (see my other comment).

We can then set the `CodeGenOpt` based on whether we are using the integrated assembler.

We could also have a separate flag for setting the codegen opt for getting this profile information, and make the driver diagnose an incompatible combination of no-integrated-as and that flag. But we'll still end up threading that flag through to Clang's codegen layer, and then into the pass manager.


================
Comment at: llvm/lib/Passes/PassBuilder.cpp:946
 
-  MPM.addPass(CGProfilePass());
+  if (EnableCallGraphProfile)
+    MPM.addPass(CGProfilePass());
----------------
We shouldn't just use the `cl::opt` here. We need a flag in the pass builder's options struct. We can default it from the `cl::opt`.

You should add a test that uses the `cl::opt` to flip the default back and forth and get the different behavior in LLVM directly against the `opt` tool. Then the LLVM part of this can land.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62627/new/

https://reviews.llvm.org/D62627





More information about the llvm-commits mailing list