[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)

Nathan Lanza via cfe-commits cfe-commits at lists.llvm.org
Fri May 3 13:23:05 PDT 2024


================
@@ -2900,7 +2900,7 @@ defm clangir : BoolFOption<"clangir",
   PosFlag<SetTrue, [], [ClangOption, CC1Option], "Use the ClangIR pipeline to compile">,
   NegFlag<SetFalse, [], [ClangOption, CC1Option], "Use the AST -> LLVM pipeline to compile">,
   BothFlags<[], [ClangOption, CC1Option], "">>;
-def emit_cir : Flag<["-"], "emit-cir">, Visibility<[CC1Option]>,
+def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>,
----------------
lanza wrote:

@erichkeane @AaronBallman @MaskRay 

I had to re-add the ClangOption here. `lib/Driver/Driver.cpp` builds the `Action` framework out based on input to the driver. So to properly orchestrate the outputs you need a driver flag to tell it that, e.g., we are emitting a `.cir` textual output. e.g. `-fsyntax-only` exists to chop off the frontend at the right point and `-emit-llvm` seems intentionally to have been made a driver flag to orchestrate `.ll` or `.bc` output.

Notably, `-emit-llvm-bc` does the wrong thing in all cases. `clang -Xclang -emit-llvm-bc hello.c` does the wrong thing and emits an executable. `clang -Xclang -emit-llvm -S hello.c` also does the wrong thing and emits a file named `hello.s` that is actually llvm bitcode. 

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


More information about the cfe-commits mailing list