LLVM  13.0.0git
LTOBackend.h
Go to the documentation of this file.
1 //===-LTOBackend.h - LLVM Link Time Optimizer Backend ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the "backend" phase of LTO, i.e. it performs
10 // optimization and code generation on a loaded module. It is generally used
11 // internally by the LTO class but can also be used independently, for example
12 // to implement a standalone ThinLTO backend.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_LTO_LTOBACKEND_H
17 #define LLVM_LTO_LTOBACKEND_H
18 
19 #include "llvm/ADT/MapVector.h"
20 #include "llvm/IR/DiagnosticInfo.h"
22 #include "llvm/LTO/LTO.h"
26 
27 namespace llvm {
28 
29 class BitcodeModule;
30 class Error;
31 class Module;
32 class Target;
33 
34 namespace lto {
35 
36 /// Runs middle-end LTO optimizations on \p Mod.
37 bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
38  bool IsThinLTO, ModuleSummaryIndex *ExportSummary,
39  const ModuleSummaryIndex *ImportSummary,
40  const std::vector<uint8_t> &CmdArgs);
41 
42 /// Runs a regular LTO backend. The regular LTO backend can also act as the
43 /// regular LTO phase of ThinLTO, which may need to access the combined index.
44 Error backend(const Config &C, AddStreamFn AddStream,
45  unsigned ParallelCodeGenParallelismLevel, Module &M,
46  ModuleSummaryIndex &CombinedIndex);
47 
48 /// Runs a ThinLTO backend.
49 /// If \p ModuleMap is not nullptr, all the module files to be imported have
50 /// already been mapped to memory and the corresponding BitcodeModule objects
51 /// are saved in the ModuleMap. If \p ModuleMap is nullptr, module files will
52 /// be mapped to memory on demand and at any given time during importing, only
53 /// one source module will be kept open at the most.
54 Error thinBackend(const Config &C, unsigned Task, AddStreamFn AddStream,
55  Module &M, const ModuleSummaryIndex &CombinedIndex,
56  const FunctionImporter::ImportMapTy &ImportList,
57  const GVSummaryMapTy &DefinedGlobals,
58  MapVector<StringRef, BitcodeModule> *ModuleMap,
59  const std::vector<uint8_t> &CmdArgs = std::vector<uint8_t>());
60 
62  std::unique_ptr<ToolOutputFile> DiagOutputFile);
63 
64 /// Returns the BitcodeModule that is ThinLTO.
65 BitcodeModule *findThinLTOModule(MutableArrayRef<BitcodeModule> BMs);
66 
67 /// Variant of the above.
68 Expected<BitcodeModule> findThinLTOModule(MemoryBufferRef MBRef);
69 
70 /// Distributed ThinLTO: collect the referenced modules based on
71 /// module summary and initialize ImportList. Returns false if the
72 /// operation failed.
73 bool initImportList(const Module &M, const ModuleSummaryIndex &CombinedIndex,
74  FunctionImporter::ImportMapTy &ImportList);
75 }
76 }
77 
78 #endif
MemoryBuffer.h
llvm
Definition: AllocatorList.h:23
llvm::lto::initImportList
bool initImportList(const Module &M, const ModuleSummaryIndex &CombinedIndex, FunctionImporter::ImportMapTy &ImportList)
Distributed ThinLTO: collect the referenced modules based on module summary and initialize ImportList...
Definition: LTOBackend.cpp:685
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::lto::finalizeOptimizationRemarks
Error finalizeOptimizationRemarks(std::unique_ptr< ToolOutputFile > DiagOutputFile)
Definition: LTOBackend.cpp:487
FunctionImport.h
MapVector.h
llvm::AMDGPU::Exp::Target
Target
Definition: SIDefines.h:732
llvm::lto::findThinLTOModule
BitcodeModule * findThinLTOModule(MutableArrayRef< BitcodeModule > BMs)
Returns the BitcodeModule that is ThinLTO.
Definition: LTOBackend.cpp:659
ModuleSummaryIndex.h
llvm::lto::opt
bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary, const std::vector< uint8_t > &CmdArgs)
Runs middle-end LTO optimizations on Mod.
Definition: LTOBackend.cpp:342
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::lto::backend
Error backend(const Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, Module &M, ModuleSummaryIndex &CombinedIndex)
Runs a regular LTO backend.
Definition: LTOBackend.cpp:498
TargetOptions.h
llvm::lto::thinBackend
Error thinBackend(const Config &C, unsigned Task, AddStreamFn AddStream, Module &M, const ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, MapVector< StringRef, BitcodeModule > *ModuleMap, const std::vector< uint8_t > &CmdArgs=std::vector< uint8_t >())
Runs a ThinLTO backend.
Definition: LTOBackend.cpp:544
llvm::GVSummaryMapTy
DenseMap< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module,...
Definition: ModuleSummaryIndex.h:994
llvm::FunctionImporter::ImportMapTy
StringMap< FunctionsToImportTy > ImportMapTy
The map contains an entry for every module to import from, the key being the module identifier to pas...
Definition: FunctionImport.h:98
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::lto::AddStreamFn
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:204
DiagnosticInfo.h
LTO.h
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47