@@ -1024,9 +1024,6 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
10241024 bool emitSummary = (opts.PrepareForThinLTO || opts.PrepareForFullLTO ) &&
10251025 (triple.getVendor () != llvm::Triple::Apple);
10261026
1027- if (emitSummary && !opts.PrepareForThinLTO )
1028- llvmModule->addModuleFlag (llvm::Module::Error, " ThinLTO" , uint32_t (0 ));
1029-
10301027 if (opts.PrepareForFatLTO )
10311028 mpm = pb.buildFatLTODefaultPipeline (level, opts.PrepareForThinLTO ,
10321029 emitSummary);
@@ -1037,12 +1034,29 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
10371034 else
10381035 mpm = pb.buildPerModuleDefaultPipeline (level);
10391036
1040- if (action == BackendActionTy::Backend_EmitBC)
1041- mpm.addPass (llvm::BitcodeWriterPass (
1042- os, /* ShouldPreserveUseListOrder=*/ false , emitSummary));
1043- else if (action == BackendActionTy::Backend_EmitLL)
1044- mpm.addPass (llvm::PrintModulePass (
1045- os, /* Banner=*/ " " , /* ShouldPreserveUseListOrder=*/ false , emitSummary));
1037+ if (action == BackendActionTy::Backend_EmitBC ||
1038+ action == BackendActionTy::Backend_EmitLL || opts.PrepareForFatLTO ) {
1039+ if (opts.PrepareForThinLTO ) {
1040+ // TODO: ThinLTO module summary support is yet to be enabled.
1041+ if (action == BackendActionTy::Backend_EmitBC)
1042+ mpm.addPass (llvm::BitcodeWriterPass (os));
1043+ else if (action == BackendActionTy::Backend_EmitLL)
1044+ mpm.addPass (llvm::PrintModulePass (os));
1045+ } else {
1046+ if (emitSummary) {
1047+ if (!llvmModule->getModuleFlag (" ThinLTO" ))
1048+ llvmModule->addModuleFlag (llvm::Module::Error, " ThinLTO" ,
1049+ uint32_t (0 ));
1050+ }
1051+ if (action == BackendActionTy::Backend_EmitBC)
1052+ mpm.addPass (llvm::BitcodeWriterPass (
1053+ os, /* ShouldPreserveUseListOrder=*/ false , emitSummary));
1054+ else if (action == BackendActionTy::Backend_EmitLL)
1055+ mpm.addPass (llvm::PrintModulePass (os, /* Banner=*/ " " ,
1056+ /* ShouldPreserveUseListOrder=*/ false ,
1057+ emitSummary));
1058+ }
1059+ }
10461060
10471061 // FIXME: This should eventually be replaced by a first-class driver option.
10481062 // This should be done for both flang and clang simultaneously.
0 commit comments