[flang-commits] [clang] [flang] [flang] Emit module summary for ThinLTO (PR #195999)
Tarun Prabhu via flang-commits
flang-commits at lists.llvm.org
Fri May 8 08:16:35 PDT 2026
================
@@ -1060,23 +1060,20 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
if (action == BackendActionTy::Backend_EmitBC ||
action == BackendActionTy::Backend_EmitLL || opts.PrepareForFatLTO) {
- if (opts.PrepareForThinLTO) {
- // TODO: ThinLTO module summary support is yet to be enabled.
- if (action == BackendActionTy::Backend_EmitBC)
- mpm.addPass(llvm::BitcodeWriterPass(os));
- else if (action == BackendActionTy::Backend_EmitLL)
- mpm.addPass(llvm::PrintModulePass(os));
- } else {
- if (emitSummary && !llvmModule->getModuleFlag("ThinLTO"))
+
+ // If it is not ThinLTO, emits the module flag and sets it to be off.
+ if (!opts.PrepareForThinLTO) {
+ if (emitSummary && !llvmModule->getModuleFlag("ThinLTO")) {
llvmModule->addModuleFlag(llvm::Module::Error, "ThinLTO", uint32_t(0));
- if (action == BackendActionTy::Backend_EmitBC)
- mpm.addPass(llvm::BitcodeWriterPass(
- os, /*ShouldPreserveUseListOrder=*/false, emitSummary));
- else if (action == BackendActionTy::Backend_EmitLL)
- mpm.addPass(llvm::PrintModulePass(os, /*Banner=*/"",
- /*ShouldPreserveUseListOrder=*/false,
- emitSummary));
+ }
}
+ if (action == BackendActionTy::Backend_EmitBC)
----------------
tarunprabhu wrote:
Per Flang's [style guide](https://flang.llvm.org/docs/C%2B%2Bstyle.html#layout), this should have braces. However, there is an exception for code "that makes heavy use of LLVM or MLIR API's. I am inclined to argue that this part of the code does, so we can probably leave it as it is.
https://github.com/llvm/llvm-project/pull/195999
More information about the flang-commits
mailing list