[clang] [CIR] Run LoweringPrepare pass only for non CIR output (PR #154107)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 21 03:13:24 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;
----------------
AmrDeveloper wrote:
> 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, ...
I was also thinking of Complex Mul & Div with different ranges, and complex builtins, but this point makes sense 👍🏻.
Also, I am thinking we should register lowering prepare to cir `opt` & `translator` because if we run the `translator` on any CIR that requires LP, it will crash because any Op that's not handled. Also, in `opt` to be able to do `cir-opt -cir-lowering-preparep`.
For the clang::ASTContext, I think we can create a default context in those tools with `getDefaultTargetTriple`, and when we need more config, we can add it as CLI args to the tool, for example, `getLangOpts().CUDA`.
What do you think? @andykaylor @bcardosolopes
https://github.com/llvm/llvm-project/pull/154107
More information about the cfe-commits
mailing list