[flang-commits] [flang] [Flang] Adjust pass plugin support to match Clang (PR #174006)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Mon Jan 5 08:34:20 PST 2026


================
@@ -882,15 +883,23 @@ getOutputStream(CompilerInstance &ci, llvm::StringRef inFile,
 /// \param [in] llvmModule LLVM module to lower to assembly/machine-code
 /// \param [in] codeGenOpts options configuring codegen pipeline
 /// \param [out] os Output stream to emit the generated code to
-static void generateMachineCodeOrAssemblyImpl(clang::DiagnosticsEngine &diags,
-                                              llvm::TargetMachine &tm,
-                                              BackendActionTy act,
-                                              llvm::Module &llvmModule,
-                                              const CodeGenOptions &codeGenOpts,
-                                              llvm::raw_pwrite_stream &os) {
+static void generateMachineCodeOrAssemblyImpl(
+    CompilerInstance &ci, clang::DiagnosticsEngine &diags,
+    llvm::TargetMachine &tm, BackendActionTy act, llvm::Module &llvmModule,
+    const CodeGenOptions &codeGenOpts, llvm::raw_pwrite_stream &os) {
   assert(((act == BackendActionTy::Backend_EmitObj) ||
           (act == BackendActionTy::Backend_EmitAssembly)) &&
          "Unsupported action");
+  llvm::CodeGenFileType cgft = (act == BackendActionTy::Backend_EmitAssembly)
+                                   ? llvm::CodeGenFileType::AssemblyFile
+                                   : llvm::CodeGenFileType::ObjectFile;
+
+  // Invoke pre-codegen callback from plugin, which might want to take over the
+  // entire code generation itself.
+  for (const std::unique_ptr<llvm::PassPlugin> &plugin : ci.getPassPlugins()) {
----------------
tarunprabhu wrote:

Braces are not necessary here

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


More information about the flang-commits mailing list