]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - ELF/LTO.h
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / 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/Common/LLVM.h"
25 #include "llvm/ADT/DenseSet.h"
26 #include "llvm/ADT/SmallString.h"
27 #include "llvm/Support/raw_ostream.h"
28 #include <memory>
29 #include <vector>
30
31 namespace llvm {
32 namespace lto {
33 class LTO;
34 }
35 } // namespace llvm
36
37 namespace lld {
38 namespace elf {
39
40 class BitcodeFile;
41 class InputFile;
42 class LazyObjFile;
43
44 class BitcodeCompiler {
45 public:
46   BitcodeCompiler();
47   ~BitcodeCompiler();
48
49   void add(BitcodeFile &F);
50   std::vector<InputFile *> compile();
51
52 private:
53   std::unique_ptr<llvm::lto::LTO> LTOObj;
54   std::vector<SmallString<0>> Buf;
55   std::vector<std::unique_ptr<MemoryBuffer>> Files;
56   llvm::DenseSet<StringRef> UsedStartStop;
57   std::unique_ptr<llvm::raw_fd_ostream> IndexFile;
58   llvm::StringMap<bool> ObjectToIndexFileState;
59 };
60 } // namespace elf
61 } // namespace lld
62
63 #endif