Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/LTO/LTOBackend.cpp
Show All 23 Lines | |||||
#include "llvm/IR/LegacyPassManager.h" | #include "llvm/IR/LegacyPassManager.h" | ||||
#include "llvm/IR/PassManager.h" | #include "llvm/IR/PassManager.h" | ||||
#include "llvm/IR/Verifier.h" | #include "llvm/IR/Verifier.h" | ||||
#include "llvm/LTO/LTO.h" | #include "llvm/LTO/LTO.h" | ||||
#include "llvm/MC/SubtargetFeature.h" | #include "llvm/MC/SubtargetFeature.h" | ||||
#include "llvm/MC/TargetRegistry.h" | #include "llvm/MC/TargetRegistry.h" | ||||
#include "llvm/Object/ModuleSymbolTable.h" | #include "llvm/Object/ModuleSymbolTable.h" | ||||
#include "llvm/Passes/PassBuilder.h" | #include "llvm/Passes/PassBuilder.h" | ||||
#include "llvm/Passes/PassPlugin.h" | #include "llvm/Passes/PassPluginRegistry.h" | ||||
#include "llvm/Passes/StandardInstrumentations.h" | #include "llvm/Passes/StandardInstrumentations.h" | ||||
#include "llvm/Support/Error.h" | #include "llvm/Support/Error.h" | ||||
#include "llvm/Support/FileSystem.h" | #include "llvm/Support/FileSystem.h" | ||||
#include "llvm/Support/MemoryBuffer.h" | #include "llvm/Support/MemoryBuffer.h" | ||||
#include "llvm/Support/Path.h" | #include "llvm/Support/Path.h" | ||||
#include "llvm/Support/Program.h" | #include "llvm/Support/Program.h" | ||||
#include "llvm/Support/ThreadPool.h" | #include "llvm/Support/ThreadPool.h" | ||||
#include "llvm/Support/ToolOutputFile.h" | #include "llvm/Support/ToolOutputFile.h" | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | Error Config::addSaveTemps(std::string OutputFileName, bool UseInputModulePath, | ||||
return Error::success(); | return Error::success(); | ||||
} | } | ||||
#define HANDLE_EXTENSION(Ext) \ | #define HANDLE_EXTENSION(Ext) \ | ||||
llvm::PassPluginLibraryInfo get##Ext##PluginInfo(); | llvm::PassPluginLibraryInfo get##Ext##PluginInfo(); | ||||
#include "llvm/Support/Extension.def" | #include "llvm/Support/Extension.def" | ||||
static void RegisterPassPlugins(ArrayRef<std::string> PassPlugins, | static void RegisterPassPlugins(PassBuilder &PB) { | ||||
PassBuilder &PB) { | |||||
#define HANDLE_EXTENSION(Ext) \ | #define HANDLE_EXTENSION(Ext) \ | ||||
get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB); | get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB); | ||||
#include "llvm/Support/Extension.def" | #include "llvm/Support/Extension.def" | ||||
// Load requested pass plugins and let them register pass builder callbacks | // Let loaded pass plugins register pass builder callbacks | ||||
for (auto &PluginFN : PassPlugins) { | for (auto const &Plugin : PassPluginRegistry::getPlugins()) { | ||||
auto PassPlugin = PassPlugin::Load(PluginFN); | Plugin.registerPassBuilderCallbacks(PB); | ||||
if (!PassPlugin) { | |||||
errs() << "Failed to load passes from '" << PluginFN | |||||
<< "'. Request ignored.\n"; | |||||
continue; | |||||
} | |||||
PassPlugin->registerPassBuilderCallbacks(PB); | |||||
} | } | ||||
} | } | ||||
static std::unique_ptr<TargetMachine> | static std::unique_ptr<TargetMachine> | ||||
createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M) { | createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M) { | ||||
StringRef TheTriple = M.getTargetTriple(); | StringRef TheTriple = M.getTargetTriple(); | ||||
SubtargetFeatures Features; | SubtargetFeatures Features; | ||||
Features.getDefaultSubtargetFeatures(Triple(TheTriple)); | Features.getDefaultSubtargetFeatures(Triple(TheTriple)); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, | ||||
CGSCCAnalysisManager CGAM; | CGSCCAnalysisManager CGAM; | ||||
ModuleAnalysisManager MAM; | ModuleAnalysisManager MAM; | ||||
PassInstrumentationCallbacks PIC; | PassInstrumentationCallbacks PIC; | ||||
StandardInstrumentations SI(Conf.DebugPassManager); | StandardInstrumentations SI(Conf.DebugPassManager); | ||||
SI.registerCallbacks(PIC, &FAM); | SI.registerCallbacks(PIC, &FAM); | ||||
PassBuilder PB(TM, Conf.PTO, PGOOpt, &PIC); | PassBuilder PB(TM, Conf.PTO, PGOOpt, &PIC); | ||||
RegisterPassPlugins(Conf.PassPlugins, PB); | RegisterPassPlugins(PB); | ||||
std::unique_ptr<TargetLibraryInfoImpl> TLII( | std::unique_ptr<TargetLibraryInfoImpl> TLII( | ||||
new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()))); | new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()))); | ||||
if (Conf.Freestanding) | if (Conf.Freestanding) | ||||
TLII->disableAllFunctions(); | TLII->disableAllFunctions(); | ||||
FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); | FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); | ||||
// Parse a custom AA pipeline if asked to. | // Parse a custom AA pipeline if asked to. | ||||
▲ Show 20 Lines • Show All 435 Lines • Show Last 20 Lines |