]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/LTO.h
Bring lld (release_39 branch, r279477) to contrib
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / ELF / LTO.h
1 //===- LTO.h ----------------------------------------------------*- C++ -*-===//
2 //
3 //                             The LLVM Linker
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 provides a way to combine bitcode files into one ELF
11 // file by compiling them using LLVM.
12 //
13 // If LTO is in use, your input files are not in regular ELF files
14 // but instead LLVM bitcode files. In that case, the linker has to
15 // convert bitcode files into the native format so that we can create
16 // an ELF file that contains native code. This file provides that
17 // functionality.
18 //
19 //===----------------------------------------------------------------------===//
20
21 #ifndef LLD_ELF_LTO_H
22 #define LLD_ELF_LTO_H
23
24 #include "lld/Core/LLVM.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/ADT/StringSet.h"
27 #include "llvm/IR/Module.h"
28 #include "llvm/Linker/IRMover.h"
29
30 namespace lld {
31 namespace elf {
32
33 class BitcodeFile;
34 class InputFile;
35
36 class BitcodeCompiler {
37 public:
38   BitcodeCompiler();
39   void add(BitcodeFile &F);
40   std::vector<std::unique_ptr<InputFile>> compile();
41
42 private:
43   std::vector<std::unique_ptr<InputFile>> runSplitCodegen(
44       const std::function<std::unique_ptr<llvm::TargetMachine>()> &TMFactory);
45
46   std::unique_ptr<llvm::Module> Combined;
47   std::vector<SmallString<0>> OwningData;
48   llvm::StringSet<> InternalizedSyms;
49   llvm::StringSet<> AsmUndefinedRefs;
50 };
51 }
52 }
53
54 #endif