]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lld/ELF/LTO.h
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lld / ELF / LTO.h
1 //===- LTO.h ----------------------------------------------------*- C++ -*-===//
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 provides a way to combine bitcode files into one ELF
10 // file by compiling them using LLVM.
11 //
12 // If LTO is in use, your input files are not in regular ELF files
13 // but instead LLVM bitcode files. In that case, the linker has to
14 // convert bitcode files into the native format so that we can create
15 // an ELF file that contains native code. This file provides that
16 // functionality.
17 //
18 //===----------------------------------------------------------------------===//
19
20 #ifndef LLD_ELF_LTO_H
21 #define LLD_ELF_LTO_H
22
23 #include "lld/Common/LLVM.h"
24 #include "llvm/ADT/DenseSet.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/Support/raw_ostream.h"
27 #include <memory>
28 #include <vector>
29
30 namespace llvm {
31 namespace lto {
32 class LTO;
33 }
34 } // namespace llvm
35
36 namespace lld {
37 namespace elf {
38
39 class BitcodeFile;
40 class InputFile;
41 class LazyObjFile;
42
43 class BitcodeCompiler {
44 public:
45   BitcodeCompiler();
46   ~BitcodeCompiler();
47
48   void add(BitcodeFile &f);
49   std::vector<InputFile *> compile();
50
51 private:
52   std::unique_ptr<llvm::lto::LTO> ltoObj;
53   std::vector<SmallString<0>> buf;
54   std::vector<std::unique_ptr<MemoryBuffer>> files;
55   llvm::DenseSet<StringRef> usedStartStop;
56   std::unique_ptr<llvm::raw_fd_ostream> indexFile;
57   llvm::DenseSet<StringRef> thinIndices;
58 };
59 } // namespace elf
60 } // namespace lld
61
62 #endif