1 //===-LTOBackend.h - LLVM Link Time Optimizer Backend ---------------------===//
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
7 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_LTO_LTOBACKEND_H
17 #define LLVM_LTO_LTOBACKEND_H
19 #include "llvm/ADT/MapVector.h"
20 #include "llvm/IR/DiagnosticInfo.h"
21 #include "llvm/IR/ModuleSummaryIndex.h"
22 #include "llvm/LTO/LTO.h"
23 #include "llvm/Support/MemoryBuffer.h"
24 #include "llvm/Target/TargetOptions.h"
25 #include "llvm/Transforms/IPO/FunctionImport.h"
36 /// Runs a regular LTO backend. The regular LTO backend can also act as the
37 /// regular LTO phase of ThinLTO, which may need to access the combined index.
38 Error
backend(Config
&C
, AddStreamFn AddStream
,
39 unsigned ParallelCodeGenParallelismLevel
,
40 std::unique_ptr
<Module
> M
, ModuleSummaryIndex
&CombinedIndex
);
42 /// Runs a ThinLTO backend.
43 Error
thinBackend(Config
&C
, unsigned Task
, AddStreamFn AddStream
, Module
&M
,
44 const ModuleSummaryIndex
&CombinedIndex
,
45 const FunctionImporter::ImportMapTy
&ImportList
,
46 const GVSummaryMapTy
&DefinedGlobals
,
47 MapVector
<StringRef
, BitcodeModule
> &ModuleMap
);