diff options
Diffstat (limited to 'lib/LTO/LTOBackend.cpp')
-rw-r--r-- | lib/LTO/LTOBackend.cpp | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/lib/LTO/LTOBackend.cpp b/lib/LTO/LTOBackend.cpp index 926c419e34a8..7456e7175163 100644 --- a/lib/LTO/LTOBackend.cpp +++ b/lib/LTO/LTOBackend.cpp @@ -1,9 +1,8 @@ //===-LTOBackend.cpp - LLVM Link Time Optimizer Backend -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -23,6 +22,7 @@ #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/PassManager.h" +#include "llvm/IR/RemarkStreamer.h" #include "llvm/IR/Verifier.h" #include "llvm/LTO/LTO.h" #include "llvm/MC/SubtargetFeature.h" @@ -33,9 +33,9 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/ThreadPool.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" @@ -155,10 +155,17 @@ static void runNewPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, const ModuleSummaryIndex *ImportSummary) { Optional<PGOOptions> PGOOpt; if (!Conf.SampleProfile.empty()) - PGOOpt = PGOOptions("", "", Conf.SampleProfile, Conf.ProfileRemapping, - false, true); + PGOOpt = PGOOptions(Conf.SampleProfile, "", Conf.ProfileRemapping, + PGOOptions::SampleUse, PGOOptions::NoCSAction, true); + else if (Conf.RunCSIRInstr) { + PGOOpt = PGOOptions("", Conf.CSIRProfile, Conf.ProfileRemapping, + PGOOptions::IRUse, PGOOptions::CSIRInstr); + } else if (!Conf.CSIRProfile.empty()) { + PGOOpt = PGOOptions(Conf.CSIRProfile, "", Conf.ProfileRemapping, + PGOOptions::IRUse, PGOOptions::CSIRUse); + } - PassBuilder PB(TM, PGOOpt); + PassBuilder PB(TM, PipelineTuningOptions(), PGOOpt); AAManager AA; // Parse a custom AA pipeline if asked to. @@ -274,6 +281,11 @@ static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, PMB.SLPVectorize = true; PMB.OptLevel = Conf.OptLevel; PMB.PGOSampleUse = Conf.SampleProfile; + PMB.EnablePGOCSInstrGen = Conf.RunCSIRInstr; + if (!Conf.RunCSIRInstr && !Conf.CSIRProfile.empty()) { + PMB.EnablePGOCSInstrUse = true; + PMB.PGOInstrUse = Conf.CSIRProfile; + } if (IsThinLTO) PMB.populateThinLTOPassManager(passes); else @@ -302,7 +314,7 @@ void codegen(Config &Conf, TargetMachine *TM, AddStreamFn AddStream, return; std::unique_ptr<ToolOutputFile> DwoOut; - SmallString<1024> DwoFile(Conf.DwoPath); + SmallString<1024> DwoFile(Conf.SplitDwarfOutput); if (!Conf.DwoDir.empty()) { std::error_code EC; if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir)) @@ -311,11 +323,12 @@ void codegen(Config &Conf, TargetMachine *TM, AddStreamFn AddStream, DwoFile = Conf.DwoDir; sys::path::append(DwoFile, std::to_string(Task) + ".dwo"); - } + TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str(); + } else + TM->Options.MCOptions.SplitDwarfFile = Conf.SplitDwarfFile; if (!DwoFile.empty()) { std::error_code EC; - TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str(); DwoOut = llvm::make_unique<ToolOutputFile>(DwoFile, EC, sys::fs::F_None); if (EC) report_fatal_error("Failed to open " + DwoFile + ": " + EC.message()); @@ -419,7 +432,8 @@ Error lto::backend(Config &C, AddStreamFn AddStream, // Setup optimization remarks. auto DiagFileOrErr = lto::setupOptimizationRemarks( - Mod->getContext(), C.RemarksFilename, C.RemarksWithHotness); + Mod->getContext(), C.RemarksFilename, C.RemarksPasses, C.RemarksFormat, + C.RemarksWithHotness); if (!DiagFileOrErr) return DiagFileOrErr.takeError(); auto DiagnosticOutputFile = std::move(*DiagFileOrErr); @@ -473,7 +487,8 @@ Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, // Setup optimization remarks. auto DiagFileOrErr = lto::setupOptimizationRemarks( - Mod.getContext(), Conf.RemarksFilename, Conf.RemarksWithHotness, Task); + Mod.getContext(), Conf.RemarksFilename, Conf.RemarksPasses, + Conf.RemarksFormat, Conf.RemarksWithHotness, Task); if (!DiagFileOrErr) return DiagFileOrErr.takeError(); auto DiagnosticOutputFile = std::move(*DiagFileOrErr); |