diff options
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 245 |
1 files changed, 160 insertions, 85 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index e765bbf637a6..3e65eeb3755d 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -16,18 +16,15 @@ #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Frontend/Utils.h" #include "clang/Lex/HeaderSearchOptions.h" -#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/Bitcode/BitcodeWriterPass.h" -#include "llvm/CodeGen/RegAllocRegistry.h" -#include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/Frontend/Driver/CodeGenOptions.h" #include "llvm/IR/DataLayout.h" @@ -39,7 +36,6 @@ #include "llvm/IR/Verifier.h" #include "llvm/IRPrinter/IRPrintingPasses.h" #include "llvm/LTO/LTOBackend.h" -#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/TargetRegistry.h" #include "llvm/Object/OffloadBinary.h" #include "llvm/Passes/PassBuilder.h" @@ -50,6 +46,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/Program.h" #include "llvm/Support/TimeProfiler.h" #include "llvm/Support/Timer.h" #include "llvm/Support/ToolOutputFile.h" @@ -64,7 +61,6 @@ #include "llvm/Transforms/IPO/LowerTypeTests.h" #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" #include "llvm/Transforms/InstCombine/InstCombine.h" -#include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Instrumentation/AddressSanitizer.h" #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h" #include "llvm/Transforms/Instrumentation/BoundsChecking.h" @@ -78,15 +74,18 @@ #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h" #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" +#include "llvm/Transforms/Instrumentation/RealtimeSanitizer.h" #include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h" #include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" +#include "llvm/Transforms/Instrumentation/TypeSanitizer.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar/EarlyCSE.h" #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Scalar/JumpThreading.h" #include "llvm/Transforms/Utils/Debugify.h" #include "llvm/Transforms/Utils/ModuleUtils.h" +#include <limits> #include <memory> #include <optional> using namespace clang; @@ -121,6 +120,9 @@ static cl::opt<PGOOptions::ColdFuncOpt> ClPGOColdFuncAttr( extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate; } // namespace llvm +namespace clang { +extern llvm::cl::opt<bool> ClSanitizeGuardChecks; +} namespace { @@ -132,16 +134,14 @@ std::string getDefaultProfileGenName() { } class EmitAssemblyHelper { + CompilerInstance &CI; DiagnosticsEngine &Diags; - const HeaderSearchOptions &HSOpts; const CodeGenOptions &CodeGenOpts; const clang::TargetOptions &TargetOpts; const LangOptions &LangOpts; llvm::Module *TheModule; IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS; - Timer CodeGenerationTime; - std::unique_ptr<raw_pwrite_stream> OS; Triple TargetTriple; @@ -206,15 +206,12 @@ class EmitAssemblyHelper { } public: - EmitAssemblyHelper(DiagnosticsEngine &_Diags, - const HeaderSearchOptions &HeaderSearchOpts, - const CodeGenOptions &CGOpts, - const clang::TargetOptions &TOpts, - const LangOptions &LOpts, llvm::Module *M, + EmitAssemblyHelper(CompilerInstance &CI, CodeGenOptions &CGOpts, + llvm::Module *M, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) - : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts), - TargetOpts(TOpts), LangOpts(LOpts), TheModule(M), VFS(std::move(VFS)), - CodeGenerationTime("codegen", "Code Generation Time"), + : CI(CI), Diags(CI.getDiagnostics()), CodeGenOpts(CGOpts), + TargetOpts(CI.getTargetOpts()), LangOpts(CI.getLangOpts()), + TheModule(M), VFS(std::move(VFS)), TargetTriple(TheModule->getTargetTriple()) {} ~EmitAssemblyHelper() { @@ -225,7 +222,7 @@ public: std::unique_ptr<TargetMachine> TM; // Emit output using the new pass manager for the optimization pipeline. - void EmitAssembly(BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS, + void emitAssembly(BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS, BackendConsumer *BC); }; } // namespace @@ -321,12 +318,46 @@ static bool actionRequiresCodeGen(BackendAction Action) { Action != Backend_EmitLL; } -static bool initTargetOptions(DiagnosticsEngine &Diags, - llvm::TargetOptions &Options, - const CodeGenOptions &CodeGenOpts, - const clang::TargetOptions &TargetOpts, - const LangOptions &LangOpts, - const HeaderSearchOptions &HSOpts) { +static std::string flattenClangCommandLine(ArrayRef<std::string> Args, + StringRef MainFilename) { + if (Args.empty()) + return std::string{}; + + std::string FlatCmdLine; + raw_string_ostream OS(FlatCmdLine); + bool PrintedOneArg = false; + if (!StringRef(Args[0]).contains("-cc1")) { + llvm::sys::printArg(OS, "-cc1", /*Quote=*/true); + PrintedOneArg = true; + } + for (unsigned i = 0; i < Args.size(); i++) { + StringRef Arg = Args[i]; + if (Arg.empty()) + continue; + if (Arg == "-main-file-name" || Arg == "-o") { + i++; // Skip this argument and next one. + continue; + } + if (Arg.starts_with("-object-file-name") || Arg == MainFilename) + continue; + // Skip fmessage-length for reproducibility. + if (Arg.starts_with("-fmessage-length")) + continue; + if (PrintedOneArg) + OS << " "; + llvm::sys::printArg(OS, Arg, /*Quote=*/true); + PrintedOneArg = true; + } + return FlatCmdLine; +} + +static bool initTargetOptions(const CompilerInstance &CI, + DiagnosticsEngine &Diags, + llvm::TargetOptions &Options) { + const auto &CodeGenOpts = CI.getCodeGenOpts(); + const auto &TargetOpts = CI.getTargetOpts(); + const auto &LangOpts = CI.getLangOpts(); + const auto &HSOpts = CI.getHeaderSearchOpts(); switch (LangOpts.getThreadModel()) { case LangOptions::ThreadModelKind::POSIX: Options.ThreadModel = llvm::ThreadModel::POSIX; @@ -395,7 +426,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, Options.BBSections = llvm::StringSwitch<llvm::BasicBlockSection>(CodeGenOpts.BBSections) .Case("all", llvm::BasicBlockSection::All) - .Case("labels", llvm::BasicBlockSection::Labels) .StartsWith("list=", llvm::BasicBlockSection::List) .Case("none", llvm::BasicBlockSection::None) .Default(llvm::BasicBlockSection::None); @@ -471,9 +501,12 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Options.MCOptions.Crel = CodeGenOpts.Crel; - Options.MCOptions.X86RelaxRelocations = CodeGenOpts.RelaxELFRelocations; + Options.MCOptions.ImplicitMapSyms = CodeGenOpts.ImplicitMapSyms; + Options.MCOptions.X86RelaxRelocations = CodeGenOpts.X86RelaxRelocations; Options.MCOptions.CompressDebugSections = CodeGenOpts.getCompressDebugSections(); + if (CodeGenOpts.OutputAsmVariant != 3) // 3 (default): not specified + Options.MCOptions.OutputAsmVariant = CodeGenOpts.OutputAsmVariant; Options.MCOptions.ABIName = TargetOpts.ABI; for (const auto &Entry : HSOpts.UserEntries) if (!Entry.IsFramework && @@ -482,8 +515,9 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, Entry.Group == frontend::IncludeDirGroup::System)) Options.MCOptions.IASSearchPaths.push_back( Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path); - Options.MCOptions.Argv0 = CodeGenOpts.Argv0; - Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs; + Options.MCOptions.Argv0 = CodeGenOpts.Argv0 ? CodeGenOpts.Argv0 : ""; + Options.MCOptions.CommandlineArgs = flattenClangCommandLine( + CodeGenOpts.CommandLineArgs, CodeGenOpts.MainFileName); Options.MCOptions.AsSecureLogFile = CodeGenOpts.AsSecureLogFile; Options.MCOptions.PPCUseFullRegisterNames = CodeGenOpts.PPCUseFullRegisterNames; @@ -567,8 +601,7 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { CodeGenOptLevel OptLevel = *OptLevelOrNone; llvm::TargetOptions Options; - if (!initTargetOptions(Diags, Options, CodeGenOpts, TargetOpts, LangOpts, - HSOpts)) + if (!initTargetOptions(CI, Diags, Options)) return; TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr, Options, RM, CM, OptLevel)); @@ -588,12 +621,6 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses, // this also adds codegenerator level optimization passes. CodeGenFileType CGFT = getCodeGenFileType(Action); - // Add ObjC ARC final-cleanup optimizations. This is done as part of the - // "codegen" passes so that it isn't run multiple times when there is - // inlining happening. - if (CodeGenOpts.OptimizationLevel > 0) - CodeGenPasses.add(createObjCARCContractPass()); - if (TM->addPassesToEmitFile(CodeGenPasses, OS, DwoOS, CGFT, /*DisableVerify=*/!CodeGenOpts.VerifyModule)) { Diags.Report(diag::err_fe_unable_to_interface_with_target); @@ -643,7 +670,7 @@ static void addKCFIPass(const Triple &TargetTriple, const LangOptions &LangOpts, // Ensure we lower KCFI operand bundles with -O0. PB.registerOptimizerLastEPCallback( - [&](ModulePassManager &MPM, OptimizationLevel Level) { + [&](ModulePassManager &MPM, OptimizationLevel Level, ThinOrFullLTOPhase) { if (Level == OptimizationLevel::O0 && LangOpts.Sanitize.has(SanitizerKind::KCFI)) MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass())); @@ -662,8 +689,8 @@ static void addKCFIPass(const Triple &TargetTriple, const LangOptions &LangOpts, static void addSanitizers(const Triple &TargetTriple, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, PassBuilder &PB) { - auto SanitizersCallback = [&](ModulePassManager &MPM, - OptimizationLevel Level) { + auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel Level, + ThinOrFullLTOPhase) { if (CodeGenOpts.hasSanitizeCoverage()) { auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); MPM.addPass(SanitizerCoveragePass( @@ -709,9 +736,15 @@ static void addSanitizers(const Triple &TargetTriple, MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); } + if (LangOpts.Sanitize.has(SanitizerKind::Type)) + MPM.addPass(TypeSanitizerPass()); + if (LangOpts.Sanitize.has(SanitizerKind::NumericalStability)) MPM.addPass(NumericalStabilitySanitizerPass()); + if (LangOpts.Sanitize.has(SanitizerKind::Realtime)) + MPM.addPass(RealtimeSanitizerPass()); + auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) { if (LangOpts.Sanitize.has(Mask)) { bool UseGlobalGC = asanUseGlobalsGC(TargetTriple, CodeGenOpts); @@ -747,9 +780,10 @@ static void addSanitizers(const Triple &TargetTriple, }; if (ClSanitizeOnOptimizerEarlyEP) { PB.registerOptimizerEarlyEPCallback( - [SanitizersCallback](ModulePassManager &MPM, OptimizationLevel Level) { + [SanitizersCallback](ModulePassManager &MPM, OptimizationLevel Level, + ThinOrFullLTOPhase Phase) { ModulePassManager NewMPM; - SanitizersCallback(NewMPM, Level); + SanitizersCallback(NewMPM, Level, Phase); if (!NewMPM.isEmpty()) { // Sanitizers can abandon<GlobalsAA>. NewMPM.addPass(RequireAnalysisPass<GlobalsAA, llvm::Module>()); @@ -762,13 +796,13 @@ static void addSanitizers(const Triple &TargetTriple, } if (LowerAllowCheckPass::IsRequested()) { - // We can optimize after inliner, and PGO profile matching. The hook below - // is called at the end `buildFunctionSimplificationPipeline`, which called - // from `buildInlinerPipeline`, which called after profile matching. - PB.registerScalarOptimizerLateEPCallback( - [](FunctionPassManager &FPM, OptimizationLevel Level) { - FPM.addPass(LowerAllowCheckPass()); - }); + // We want to call it after inline, which is about OptimizerEarlyEPCallback. + PB.registerOptimizerEarlyEPCallback([&](ModulePassManager &MPM, + OptimizationLevel Level, + ThinOrFullLTOPhase Phase) { + LowerAllowCheckPass::Options Opts; + MPM.addPass(createModuleToFunctionPassAdaptor(LowerAllowCheckPass(Opts))); + }); } } @@ -962,7 +996,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline( createModuleToFunctionPassAdaptor(ObjCARCExpandPass())); }); PB.registerPipelineEarlySimplificationEPCallback( - [](ModulePassManager &MPM, OptimizationLevel Level) { + [](ModulePassManager &MPM, OptimizationLevel Level, + ThinOrFullLTOPhase) { if (Level != OptimizationLevel::O0) MPM.addPass(ObjCARCAPElimPass()); }); @@ -982,18 +1017,39 @@ void EmitAssemblyHelper::RunOptimizationPipeline( if (IsThinLTOPostLink) PB.registerPipelineStartEPCallback( [](ModulePassManager &MPM, OptimizationLevel Level) { - MPM.addPass(LowerTypeTestsPass(/*ExportSummary=*/nullptr, - /*ImportSummary=*/nullptr, - /*DropTypeTests=*/true)); + MPM.addPass(LowerTypeTestsPass( + /*ExportSummary=*/nullptr, + /*ImportSummary=*/nullptr, + /*DropTypeTests=*/lowertypetests::DropTestKind::Assume)); }); // Register callbacks to schedule sanitizer passes at the appropriate part // of the pipeline. if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) - PB.registerScalarOptimizerLateEPCallback( - [](FunctionPassManager &FPM, OptimizationLevel Level) { - FPM.addPass(BoundsCheckingPass()); - }); + PB.registerScalarOptimizerLateEPCallback([this](FunctionPassManager &FPM, + OptimizationLevel Level) { + BoundsCheckingPass::Options Options; + if (CodeGenOpts.SanitizeSkipHotCutoffs[SanitizerKind::SO_LocalBounds] || + ClSanitizeGuardChecks) { + static_assert(SanitizerKind::SO_LocalBounds <= + std::numeric_limits< + decltype(Options.GuardKind)::value_type>::max(), + "Update type of llvm.allow.ubsan.check to represent " + "SanitizerKind::SO_LocalBounds."); + Options.GuardKind = SanitizerKind::SO_LocalBounds; + } + Options.Merge = + CodeGenOpts.SanitizeMergeHandlers.has(SanitizerKind::LocalBounds); + if (!CodeGenOpts.SanitizeTrap.has(SanitizerKind::LocalBounds)) { + Options.Rt = { + /*MinRuntime=*/static_cast<bool>( + CodeGenOpts.SanitizeMinimalRuntime), + /*MayReturn=*/ + CodeGenOpts.SanitizeRecover.has(SanitizerKind::LocalBounds), + }; + } + FPM.addPass(BoundsCheckingPass(Options)); + }); // Don't add sanitizers if we are here from ThinLTO PostLink. That already // done on PreLink stage. @@ -1018,11 +1074,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline( // TODO: Consider passing the MemoryProfileOutput to the pass builder via // the PGOOptions, and set this up there. if (!CodeGenOpts.MemoryProfileOutput.empty()) { - PB.registerOptimizerLastEPCallback( - [](ModulePassManager &MPM, OptimizationLevel Level) { - MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass())); - MPM.addPass(ModuleMemProfilerPass()); - }); + PB.registerOptimizerLastEPCallback([](ModulePassManager &MPM, + OptimizationLevel Level, + ThinOrFullLTOPhase) { + MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass())); + MPM.addPass(ModuleMemProfilerPass()); + }); } if (CodeGenOpts.FatLTO) { @@ -1092,6 +1149,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline( TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1)); } + // FIXME: This should eventually be replaced by a first-class driver option. + // This should be done for both clang and flang simultaneously. // Print a textual, '-passes=' compatible, representation of pipeline if // requested. if (PrintPipelinePasses) { @@ -1111,7 +1170,14 @@ void EmitAssemblyHelper::RunOptimizationPipeline( { PrettyStackTraceString CrashInfo("Optimizer"); llvm::TimeTraceScope TimeScope("Optimizer"); + Timer timer; + if (CI.getCodeGenOpts().TimePasses) { + timer.init("optimizer", "Optimizer", CI.getTimerGroup()); + CI.getFrontendTimer().yieldTo(timer); + } MPM.run(*TheModule, MAM); + if (CI.getCodeGenOpts().TimePasses) + timer.yieldTo(CI.getFrontendTimer()); } } @@ -1154,14 +1220,20 @@ void EmitAssemblyHelper::RunCodegenPipeline( { PrettyStackTraceString CrashInfo("Code generation"); llvm::TimeTraceScope TimeScope("CodeGenPasses"); + Timer timer; + if (CI.getCodeGenOpts().TimePasses) { + timer.init("codegen", "Machine code generation", CI.getTimerGroup()); + CI.getFrontendTimer().yieldTo(timer); + } CodeGenPasses.run(*TheModule); + if (CI.getCodeGenOpts().TimePasses) + timer.yieldTo(CI.getFrontendTimer()); } } -void EmitAssemblyHelper::EmitAssembly(BackendAction Action, +void EmitAssemblyHelper::emitAssembly(BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS, BackendConsumer *BC) { - TimeRegion Region(CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr); setCommandLineOpts(CodeGenOpts); bool RequiresCodeGen = actionRequiresCodeGen(Action); @@ -1185,13 +1257,14 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, DwoOS->keep(); } -static void runThinLTOBackend( - DiagnosticsEngine &Diags, ModuleSummaryIndex *CombinedIndex, - llvm::Module *M, const HeaderSearchOptions &HeaderOpts, - const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts, - const LangOptions &LOpts, std::unique_ptr<raw_pwrite_stream> OS, - std::string SampleProfile, std::string ProfileRemapping, - BackendAction Action) { +static void +runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex, + llvm::Module *M, std::unique_ptr<raw_pwrite_stream> OS, + std::string SampleProfile, std::string ProfileRemapping, + BackendAction Action) { + DiagnosticsEngine &Diags = CI.getDiagnostics(); + const auto &CGOpts = CI.getCodeGenOpts(); + const auto &TOpts = CI.getTargetOpts(); DenseMap<StringRef, DenseMap<GlobalValue::GUID, GlobalValueSummary *>> ModuleToDefinedGVSummaries; CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); @@ -1201,7 +1274,8 @@ static void runThinLTOBackend( // We can simply import the values mentioned in the combined index, since // we should only invoke this using the individual indexes written out // via a WriteIndexesThinBackend. - FunctionImporter::ImportMapTy ImportList; + FunctionImporter::ImportIDTable ImportIDs; + FunctionImporter::ImportMapTy ImportList(ImportIDs); if (!lto::initImportList(*M, *CombinedIndex, ImportList)) return; @@ -1228,7 +1302,7 @@ static void runThinLTOBackend( assert(OptLevelOrNone && "Invalid optimization level!"); Conf.CGOptLevel = *OptLevelOrNone; Conf.OptLevel = CGOpts.OptimizationLevel; - initTargetOptions(Diags, Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts); + initTargetOptions(CI, Diags, Conf.Options); Conf.SampleProfile = std::move(SampleProfile); Conf.PTO.LoopUnrolling = CGOpts.UnrollLoops; // For historical reasons, loop interleaving is set to mirror setting for loop @@ -1283,21 +1357,22 @@ static void runThinLTOBackend( if (Error E = thinBackend(Conf, -1, AddStream, *M, *CombinedIndex, ImportList, ModuleToDefinedGVSummaries[M->getModuleIdentifier()], - /* ModuleMap */ nullptr, CGOpts.CmdArgs)) { + /*ModuleMap=*/nullptr, Conf.CodeGenOnly, + /*IRAddStream=*/nullptr, CGOpts.CmdArgs)) { handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) { errs() << "Error running ThinLTO backend: " << EIB.message() << '\n'; }); } } -void clang::EmitBackendOutput( - DiagnosticsEngine &Diags, const HeaderSearchOptions &HeaderOpts, - const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts, - const LangOptions &LOpts, StringRef TDesc, llvm::Module *M, - BackendAction Action, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, - std::unique_ptr<raw_pwrite_stream> OS, BackendConsumer *BC) { - +void clang::emitBackendOutput(CompilerInstance &CI, CodeGenOptions &CGOpts, + StringRef TDesc, llvm::Module *M, + BackendAction Action, + IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, + std::unique_ptr<raw_pwrite_stream> OS, + BackendConsumer *BC) { llvm::TimeTraceScope TimeScope("Backend"); + DiagnosticsEngine &Diags = CI.getDiagnostics(); std::unique_ptr<llvm::Module> EmptyModule; if (!CGOpts.ThinLTOIndexFile.empty()) { @@ -1320,9 +1395,9 @@ void clang::EmitBackendOutput( // of an error). if (CombinedIndex) { if (!CombinedIndex->skipModuleByDistributedBackend()) { - runThinLTOBackend(Diags, CombinedIndex.get(), M, HeaderOpts, CGOpts, - TOpts, LOpts, std::move(OS), CGOpts.SampleProfileFile, - CGOpts.ProfileRemappingFile, Action); + runThinLTOBackend(CI, CombinedIndex.get(), M, std::move(OS), + CGOpts.SampleProfileFile, CGOpts.ProfileRemappingFile, + Action); return; } // Distributed indexing detected that nothing from the module is needed @@ -1337,8 +1412,8 @@ void clang::EmitBackendOutput( } } - EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M, VFS); - AsmHelper.EmitAssembly(Action, std::move(OS), BC); + EmitAssemblyHelper AsmHelper(CI, CGOpts, M, VFS); + AsmHelper.emitAssembly(Action, std::move(OS), BC); // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's // DataLayout. |