[clang] [CIR] Run LoweringPrepare pass only for non CIR output (PR #154107)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 20 15:46:09 PDT 2025


================
@@ -110,9 +110,10 @@ class CIRGenConsumer : public clang::ASTConsumer {
 
     if (!FEOptions.ClangIRDisablePasses) {
       // Setup and run CIR pipeline.
+      bool EnableLoweringPrepare = Action != CIRGenAction::OutputType::EmitCIR;
----------------
bcardosolopes wrote:

Althought this is good rationale, I'm still a bit skeptical we need this right now (given the amount of work versus benefit).

It seems reasonable to have the CIR output (`-emit-cir`) to be driven similarly to how LLVM does, meaning: `-emit-llvm` outputs happens after the last pass ran, so it's driven by -disable-llvm-opts, -O0, -O1, ... 

We already have `-clangir-disable-passes` which should make CIR emission to stop right after CIRGen. For all other passes I'd expect that the CIR output could also be driven by O0, O1, etc.
Why isn't `-clangir-disable-passes` good enough for complex testing or putting it differently, why shoud we be different from `-emit-llvm` in that respect? When investigating OG codegen I often have to resort to `-disable-llvm-opts` to get the "true" output before the set of basic optimizations that run (even at -O0), seems consistent to do similar with CIR.

https://github.com/llvm/llvm-project/pull/154107


More information about the cfe-commits mailing list