LLVM  4.0.0
LTOBackend.cpp
Go to the documentation of this file.
1 //===-LTOBackend.cpp - LLVM Link Time Optimizer Backend -------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the "backend" phase of LTO, i.e. it performs
11 // optimization and code generation on a loaded module. It is generally used
12 // internally by the LTO class but can also be used independently, for example
13 // to implement a standalone ThinLTO backend.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #include "llvm/LTO/LTOBackend.h"
25 #include "llvm/IR/PassManager.h"
26 #include "llvm/IR/Verifier.h"
27 #include "llvm/LTO/LTO.h"
31 #include "llvm/Support/Error.h"
36 #include "llvm/Transforms/IPO.h"
41 
42 using namespace llvm;
43 using namespace lto;
44 
46  errs() << "failed to open " << Path << ": " << Msg << '\n';
47  errs().flush();
48  exit(1);
49 }
50 
51 Error Config::addSaveTemps(std::string OutputFileName,
52  bool UseInputModulePath) {
54 
55  std::error_code EC;
56  ResolutionFile = llvm::make_unique<raw_fd_ostream>(
57  OutputFileName + "resolution.txt", EC, sys::fs::OpenFlags::F_Text);
58  if (EC)
59  return errorCodeToError(EC);
60 
61  auto setHook = [&](std::string PathSuffix, ModuleHookFn &Hook) {
62  // Keep track of the hook provided by the linker, which also needs to run.
63  ModuleHookFn LinkerHook = Hook;
64  Hook = [=](unsigned Task, const Module &M) {
65  // If the linker's hook returned false, we need to pass that result
66  // through.
67  if (LinkerHook && !LinkerHook(Task, M))
68  return false;
69 
70  std::string PathPrefix;
71  // If this is the combined module (not a ThinLTO backend compile) or the
72  // user hasn't requested using the input module's path, emit to a file
73  // named from the provided OutputFileName with the Task ID appended.
74  if (M.getModuleIdentifier() == "ld-temp.o" || !UseInputModulePath) {
75  PathPrefix = OutputFileName + utostr(Task);
76  } else
77  PathPrefix = M.getModuleIdentifier();
78  std::string Path = PathPrefix + "." + PathSuffix + ".bc";
79  std::error_code EC;
81  // Because -save-temps is a debugging feature, we report the error
82  // directly and exit.
83  if (EC)
84  reportOpenError(Path, EC.message());
85  WriteBitcodeToFile(&M, OS, /*ShouldPreserveUseListOrder=*/false);
86  return true;
87  };
88  };
89 
90  setHook("0.preopt", PreOptModuleHook);
91  setHook("1.promote", PostPromoteModuleHook);
92  setHook("2.internalize", PostInternalizeModuleHook);
93  setHook("3.import", PostImportModuleHook);
94  setHook("4.opt", PostOptModuleHook);
95  setHook("5.precodegen", PreCodeGenModuleHook);
96 
97  CombinedIndexHook = [=](const ModuleSummaryIndex &Index) {
98  std::string Path = OutputFileName + "index.bc";
99  std::error_code EC;
101  // Because -save-temps is a debugging feature, we report the error
102  // directly and exit.
103  if (EC)
104  reportOpenError(Path, EC.message());
105  WriteIndexToFile(Index, OS);
106  return true;
107  };
108 
109  return Error::success();
110 }
111 
112 namespace {
113 
114 std::unique_ptr<TargetMachine>
115 createTargetMachine(Config &Conf, StringRef TheTriple,
116  const Target *TheTarget) {
118  Features.getDefaultSubtargetFeatures(Triple(TheTriple));
119  for (const std::string &A : Conf.MAttrs)
120  Features.AddFeature(A);
121 
122  return std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
123  TheTriple, Conf.CPU, Features.getString(), Conf.Options, Conf.RelocModel,
124  Conf.CodeModel, Conf.CGOptLevel));
125 }
126 
127 static void runNewPMCustomPasses(Module &Mod, TargetMachine *TM,
128  std::string PipelineDesc,
129  std::string AAPipelineDesc,
130  bool DisableVerify) {
131  PassBuilder PB(TM);
132  AAManager AA;
133 
134  // Parse a custom AA pipeline if asked to.
135  if (!AAPipelineDesc.empty())
136  if (!PB.parseAAPipeline(AA, AAPipelineDesc))
137  report_fatal_error("unable to parse AA pipeline description: " +
138  AAPipelineDesc);
139 
144 
145  // Register the AA manager first so that our version is the one used.
146  FAM.registerPass([&] { return std::move(AA); });
147 
148  // Register all the basic analyses with the managers.
149  PB.registerModuleAnalyses(MAM);
150  PB.registerCGSCCAnalyses(CGAM);
151  PB.registerFunctionAnalyses(FAM);
152  PB.registerLoopAnalyses(LAM);
153  PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
154 
155  ModulePassManager MPM;
156 
157  // Always verify the input.
158  MPM.addPass(VerifierPass());
159 
160  // Now, add all the passes we've been requested to.
161  if (!PB.parsePassPipeline(MPM, PipelineDesc))
162  report_fatal_error("unable to parse pass pipeline description: " +
163  PipelineDesc);
164 
165  if (!DisableVerify)
166  MPM.addPass(VerifierPass());
167  MPM.run(Mod, MAM);
168 }
169 
170 static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM,
171  bool IsThinLTO) {
172  legacy::PassManager passes;
174 
175  PassManagerBuilder PMB;
178  // Unconditionally verify input since it is not verified before this
179  // point and has unknown origin.
180  PMB.VerifyInput = true;
181  PMB.VerifyOutput = !Conf.DisableVerify;
182  PMB.LoopVectorize = true;
183  PMB.SLPVectorize = true;
184  PMB.OptLevel = Conf.OptLevel;
185  PMB.PGOSampleUse = Conf.SampleProfile;
186  if (IsThinLTO)
187  PMB.populateThinLTOPassManager(passes);
188  else
189  PMB.populateLTOPassManager(passes);
190  passes.run(Mod);
191 }
192 
193 bool opt(Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
194  bool IsThinLTO) {
195  if (Conf.OptPipeline.empty())
196  runOldPMPasses(Conf, Mod, TM, IsThinLTO);
197  else
198  runNewPMCustomPasses(Mod, TM, Conf.OptPipeline, Conf.AAPipeline,
199  Conf.DisableVerify);
200  return !Conf.PostOptModuleHook || Conf.PostOptModuleHook(Task, Mod);
201 }
202 
203 void codegen(Config &Conf, TargetMachine *TM, AddStreamFn AddStream,
204  unsigned Task, Module &Mod) {
205  if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task, Mod))
206  return;
207 
208  auto Stream = AddStream(Task);
209  legacy::PassManager CodeGenPasses;
210  if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS,
212  report_fatal_error("Failed to setup codegen");
213  CodeGenPasses.run(Mod);
214 }
215 
216 void splitCodeGen(Config &C, TargetMachine *TM, AddStreamFn AddStream,
217  unsigned ParallelCodeGenParallelismLevel,
218  std::unique_ptr<Module> Mod) {
219  ThreadPool CodegenThreadPool(ParallelCodeGenParallelismLevel);
220  unsigned ThreadCount = 0;
221  const Target *T = &TM->getTarget();
222 
223  SplitModule(
224  std::move(Mod), ParallelCodeGenParallelismLevel,
225  [&](std::unique_ptr<Module> MPart) {
226  // We want to clone the module in a new context to multi-thread the
227  // codegen. We do it by serializing partition modules to bitcode
228  // (while still on the main thread, in order to avoid data races) and
229  // spinning up new threads which deserialize the partitions into
230  // separate contexts.
231  // FIXME: Provide a more direct way to do this in LLVM.
232  SmallString<0> BC;
233  raw_svector_ostream BCOS(BC);
234  WriteBitcodeToFile(MPart.get(), BCOS);
235 
236  // Enqueue the task
237  CodegenThreadPool.async(
238  [&](const SmallString<0> &BC, unsigned ThreadId) {
239  LTOLLVMContext Ctx(C);
241  MemoryBufferRef(StringRef(BC.data(), BC.size()), "ld-temp.o"),
242  Ctx);
243  if (!MOrErr)
244  report_fatal_error("Failed to read bitcode");
245  std::unique_ptr<Module> MPartInCtx = std::move(MOrErr.get());
246 
247  std::unique_ptr<TargetMachine> TM =
248  createTargetMachine(C, MPartInCtx->getTargetTriple(), T);
249 
250  codegen(C, TM.get(), AddStream, ThreadId, *MPartInCtx);
251  },
252  // Pass BC using std::move to ensure that it get moved rather than
253  // copied into the thread's context.
254  std::move(BC), ThreadCount++);
255  },
256  false);
257 
258  // Because the inner lambda (which runs in a worker thread) captures our local
259  // variables, we need to wait for the worker threads to terminate before we
260  // can leave the function scope.
261  CodegenThreadPool.wait();
262 }
263 
264 Expected<const Target *> initAndLookupTarget(Config &C, Module &Mod) {
265  if (!C.OverrideTriple.empty())
267  else if (Mod.getTargetTriple().empty())
269 
270  std::string Msg;
271  const Target *T = TargetRegistry::lookupTarget(Mod.getTargetTriple(), Msg);
272  if (!T)
273  return make_error<StringError>(Msg, inconvertibleErrorCode());
274  return T;
275 }
276 
277 }
278 
280  // Collect the list of undefined symbols used in asm and update
281  // llvm.compiler.used to prevent optimization to drop these from the output.
282  StringSet<> AsmUndefinedRefs;
285  [&AsmUndefinedRefs](StringRef Name, object::BasicSymbolRef::Flags Flags) {
287  AsmUndefinedRefs.insert(Name);
288  });
289  updateCompilerUsed(Mod, TM, AsmUndefinedRefs);
290 }
291 
293  unsigned ParallelCodeGenParallelismLevel,
294  std::unique_ptr<Module> Mod) {
295  Expected<const Target *> TOrErr = initAndLookupTarget(C, *Mod);
296  if (!TOrErr)
297  return TOrErr.takeError();
298 
299  std::unique_ptr<TargetMachine> TM =
300  createTargetMachine(C, Mod->getTargetTriple(), *TOrErr);
301 
302  handleAsmUndefinedRefs(*Mod, *TM);
303 
304  if (!C.CodeGenOnly)
305  if (!opt(C, TM.get(), 0, *Mod, /*IsThinLTO=*/false))
306  return Error::success();
307 
308  if (ParallelCodeGenParallelismLevel == 1) {
309  codegen(C, TM.get(), AddStream, 0, *Mod);
310  } else {
311  splitCodeGen(C, TM.get(), AddStream, ParallelCodeGenParallelismLevel,
312  std::move(Mod));
313  }
314  return Error::success();
315 }
316 
317 Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream,
318  Module &Mod, ModuleSummaryIndex &CombinedIndex,
319  const FunctionImporter::ImportMapTy &ImportList,
320  const GVSummaryMapTy &DefinedGlobals,
322  Expected<const Target *> TOrErr = initAndLookupTarget(Conf, Mod);
323  if (!TOrErr)
324  return TOrErr.takeError();
325 
326  std::unique_ptr<TargetMachine> TM =
327  createTargetMachine(Conf, Mod.getTargetTriple(), *TOrErr);
328 
329  handleAsmUndefinedRefs(Mod, *TM);
330 
331  if (Conf.CodeGenOnly) {
332  codegen(Conf, TM.get(), AddStream, Task, Mod);
333  return Error::success();
334  }
335 
336  if (Conf.PreOptModuleHook && !Conf.PreOptModuleHook(Task, Mod))
337  return Error::success();
338 
339  renameModuleForThinLTO(Mod, CombinedIndex);
340 
341  thinLTOResolveWeakForLinkerModule(Mod, DefinedGlobals);
342 
343  if (Conf.PostPromoteModuleHook && !Conf.PostPromoteModuleHook(Task, Mod))
344  return Error::success();
345 
346  if (!DefinedGlobals.empty())
347  thinLTOInternalizeModule(Mod, DefinedGlobals);
348 
349  if (Conf.PostInternalizeModuleHook &&
350  !Conf.PostInternalizeModuleHook(Task, Mod))
351  return Error::success();
352 
353  auto ModuleLoader = [&](StringRef Identifier) {
355  "ODR Type uniquing should be enabled on the context");
356  auto I = ModuleMap.find(Identifier);
357  assert(I != ModuleMap.end());
358  return I->second.getLazyModule(Mod.getContext(),
359  /*ShouldLazyLoadMetadata=*/true,
360  /*IsImporting*/ true);
361  };
362 
363  FunctionImporter Importer(CombinedIndex, ModuleLoader);
364  if (Error Err = Importer.importFunctions(Mod, ImportList).takeError())
365  return Err;
366 
367  if (Conf.PostImportModuleHook && !Conf.PostImportModuleHook(Task, Mod))
368  return Error::success();
369 
370  if (!opt(Conf, TM.get(), Task, Mod, /*IsThinLTO=*/true))
371  return Error::success();
372 
373  codegen(Conf, TM.get(), AddStream, Task, Mod);
374  return Error::success();
375 }
static void codegen(Module *M, llvm::raw_pwrite_stream &OS, function_ref< std::unique_ptr< TargetMachine >()> TMFactory, TargetMachine::CodeGenFileType FileType)
Definition: ParallelCG.cpp:29
Interfaces for registering analysis passes, producing common pass manager configurations, and parsing of pass pipelines.
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs...ExtraArgs)
Run all of the passes in this manager over the given unit of IR.
Definition: PassManager.h:413
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
std::string CPU
Definition: Config.h:38
std::string AAPipeline
Definition: Config.h:58
CodeGenOpt::Level CGOptLevel
Definition: Config.h:43
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void getDefaultSubtargetFeatures(const Triple &Triple)
Adds the default features for the specified target triple.
This header provides classes for managing a pipeline of passes over loops in LLVM IR...
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
bool ShouldDiscardValueNames
Definition: Config.h:71
std::string OverrideTriple
Setting this field will replace target triples in input files with this triple.
Definition: Config.h:62
void populateThinLTOPassManager(legacy::PassManagerBase &PM)
bool CodeGenOnly
Disable entirely the optimizer, including importing for ThinLTO.
Definition: Config.h:48
void SplitModule(std::unique_ptr< Module > M, unsigned N, function_ref< void(std::unique_ptr< Module > MPart)> ModuleCallback, bool PreserveLocals=false)
Splits the module M into N linkable partitions.
std::unique_ptr< raw_ostream > ResolutionFile
If this field is set, LTO will write input file paths and symbol resolutions here in llvm-lto2 comman...
Definition: Config.h:78
ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
Implementation of the target library information.
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:32
std::string PGOSampleUse
Path of the sample Profile data file.
Error takeError()
Take ownership of the stored error.
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:218
ModuleHookFn PreCodeGenModuleHook
This module hook is called before code generation.
Definition: Config.h:126
Expected< bool > importFunctions(Module &M, const ImportMapTy &ImportList, bool ForceImportReferencedDiscardableSymbols=false)
Import functions in Module M based on the supplied import list.
Pass * Inliner
Inliner - Specifies the inliner to use.
CombinedIndexHookFn CombinedIndexHook
Definition: Config.h:139
const Triple & getTargetTriple() const
std::function< std::unique_ptr< NativeObjectStream >unsigned Task)> AddStreamFn
This type defines the callback to add a native object that is generated on the fly.
Definition: LTO.h:253
static void handleAsmUndefinedRefs(Module &Mod, TargetMachine &TM)
Definition: LTOBackend.cpp:279
void add(Pass *P) override
Add a pass to the queue of passes to run.
bool isODRUniquingDebugTypes() const
Whether there is a string map for uniquing debug info identifiers across the context.
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
std::vector< std::string > MAttrs
Definition: Config.h:40
void populateLTOPassManager(legacy::PassManagerBase &PM)
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
Definition: PassManager.h:702
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:36
std::function< bool(unsigned Task, const Module &)> ModuleHookFn
The following callbacks deal with tasks, which normally represent the entire optimization and code ge...
Definition: Config.h:104
Tagged union holding either a T or a Error.
void AddFeature(StringRef String, bool Enable=true)
Adding Features.
bool DisableVerify
Definition: Config.h:45
#define T
unsigned OptLevel
The Optimization Level - Specify the basic optimization level.
std::string SampleProfile
Sample PGO profile path.
Definition: Config.h:69
TargetOptions Options
Definition: Config.h:39
static std::string utostr(uint64_t X, bool isNeg=false)
Definition: StringExtras.h:79
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
A ThreadPool for asynchronous parallel execution on a defined number of threads.
Definition: ThreadPool.h:51
Class to hold module path string table and global value map, and encapsulate methods for operating on...
iterator find(const KeyT &Key)
Definition: MapVector.h:131
PassManager manages ModulePassManagers.
ModuleHookFn PreOptModuleHook
This module hook is called after linking (regular LTO) or loading (ThinLTO) the module, before modifying it.
Definition: Config.h:108
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
TargetLibraryInfoImpl * LibraryInfo
LibraryInfo - Specifies information about the runtime library for the optimizer.
A manager for alias analyses.
virtual TargetIRAnalysis getTargetIRAnalysis()
Get a TargetIRAnalysis appropriate for the target.
unsigned OptLevel
Definition: Config.h:44
LTO configuration.
Definition: Config.h:35
std::string DefaultTriple
Setting this field will replace unspecified target triples in input files with this triple...
Definition: Config.h:66
ModuleHookFn PostInternalizeModuleHook
This hook is called after internalizing the module.
Definition: Config.h:115
std::string getString() const
Features string accessors.
bool run(Module &M)
run - Execute all of the passes scheduled for execution.
Create a verifier pass.
Definition: Verifier.h:129
std::pair< typename base::iterator, bool > insert(StringRef Key)
Definition: StringSet.h:32
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
Definition: Module.h:226
Error thinBackend(Config &C, unsigned Task, AddStreamFn AddStream, Module &M, ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, MapVector< StringRef, BitcodeModule > &ModuleMap)
Runs a ThinLTO backend.
Definition: LTOBackend.cpp:317
static ErrorSuccess success()
Create a success value.
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Optional< Reloc::Model > RM, CodeModel::Model CM=CodeModel::Default, CodeGenOpt::Level OL=CodeGenOpt::Default) const
createTargetMachine - Create a target specific machine implementation for the specified Triple...
virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &, CodeGenFileType, bool=true, AnalysisID=nullptr, AnalysisID=nullptr, AnalysisID=nullptr, AnalysisID=nullptr, MachineFunctionInitializer *=nullptr)
Add passes to the specified pass manager to get the specified file emitted.
#define LLVM_ATTRIBUTE_NORETURN
Definition: Compiler.h:212
bool renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, DenseSet< const GlobalValue * > *GlobalsToImport=nullptr)
Perform in-place global value handling on the given Module for exported local functions renamed and p...
reference get()
Returns a reference to the stored T value.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:223
Target - Wrapper for Target specific information.
SubtargetFeatures - Manages the enabling and disabling of subtarget specific features.
std::string OptPipeline
If this field is set, the set of passes run in the middle-end optimizer will be the one specified by ...
Definition: Config.h:53
void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map< std::string, GVSummaryMapTy > *ModuleToSummariesForIndex=nullptr)
Write the specified module summary index to the given raw output stream, where it will be written in ...
The file should be opened in text mode on platforms that make this distinction.
Definition: FileSystem.h:638
Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context)
Read the specified bitcode file, returning the module.
std::map< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module...
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:357
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition: SmallVector.h:142
Manages a sequence of passes over a particular unit of IR.
Definition: PassManager.h:389
void WriteBitcodeToFile(const Module *M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false)
Write the specified module to the specified raw output stream.
Reloc::Model RelocModel
Definition: Config.h:41
Error backend(Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, std::unique_ptr< Module > M)
Runs a regular LTO backend.
Definition: LTOBackend.cpp:292
#define I(x, y, z)
Definition: MD5.cpp:54
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:135
void thinLTOInternalizeModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals)
Internalize TheModule based on the information recorded in the summaries during global summary-based ...
void setTargetTriple(StringRef T)
Set the target triple.
Definition: Module.h:254
CodeModel::Model CodeModel
Definition: Config.h:42
void thinLTOResolveWeakForLinkerModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals)
Resolve WeakForLinker values in TheModule based on the information recorded in the summaries during g...
This header provides classes for managing passes over SCCs of the call graph.
void updateCompilerUsed(Module &TheModule, const TargetMachine &TM, const StringSet<> &AsmUndefinedRefs)
Find all globals in TheModule that are referenced in AsmUndefinedRefs, as well as the user-supplied f...
ModuleHookFn PostImportModuleHook
This hook is called after importing from other modules (ThinLTO-specific).
Definition: Config.h:118
iterator end()
Definition: MapVector.h:55
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void CollectAsmSymbols(const Triple &TheTriple, StringRef InlineAsm, function_ref< void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol)
Parse inline ASM and collect the symbols that are defined or referenced in the current module...
Pass * createFunctionInliningPass()
createFunctionInliningPass - Return a new pass object that uses a heuristic to inline direct function...
The function importer is automatically importing function from other modules based on the provided su...
Lightweight error class with error context and mandatory checking.
const FeatureBitset Features
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:23
ModuleHookFn PostOptModuleHook
This module hook is called after optimization is complete.
Definition: Config.h:121
const Target & getTarget() const
Primary interface to the complete machine description for the target machine.
Error addSaveTemps(std::string OutputFileName, bool UseInputModulePath=false)
This is a convenience function that configures this Config object to write temporary files named afte...
Definition: LTOBackend.cpp:51
A derived class of LLVMContext that initializes itself according to a given Config object...
Definition: Config.h:164
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
A container for analyses that lazily runs them and caches their results.
void addPass(PassT Pass)
Definition: PassManager.h:454
static LLVM_ATTRIBUTE_NORETURN void reportOpenError(StringRef Path, Twine Msg)
Definition: LTOBackend.cpp:45
This pass exposes codegen information to IR-level passes.
This header defines various interfaces for pass management in LLVM.
ModuleHookFn PostPromoteModuleHook
This hook is called after promoting any internal functions (ThinLTO-specific).
Definition: Config.h:112
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
std::unique_ptr< Module > splitCodeGen(std::unique_ptr< Module > M, ArrayRef< raw_pwrite_stream * > OSs, ArrayRef< llvm::raw_pwrite_stream * > BCOSs, const std::function< std::unique_ptr< TargetMachine >()> &TMFactory, TargetMachine::CodeGenFileType FT=TargetMachine::CGFT_ObjectFile, bool PreserveLocals=false)
Split M into OSs.size() partitions, and generate code for each.
Definition: ParallelCG.cpp:39
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:222
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...