1 //===- LTO.h ----------------------------------------------------*- C++ -*-===//
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 provides a way to combine bitcode files into one COFF
10 // file by compiling them using LLVM.
12 // If LTO is in use, your input files are not in regular COFF 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 // a COFF file that contains native code. This file provides that
18 //===----------------------------------------------------------------------===//
20 #ifndef LLD_COFF_LTO_H
21 #define LLD_COFF_LTO_H
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"
41 class COFFLinkerContext
;
43 class BitcodeCompiler
{
48 void add(BitcodeFile
&f
);
49 std::vector
<InputFile
*> compile(COFFLinkerContext
&ctx
);
52 std::unique_ptr
<llvm::lto::LTO
> ltoObj
;
53 std::vector
<SmallString
<0>> buf
;
54 std::vector
<std::unique_ptr
<MemoryBuffer
>> files
;
55 std::unique_ptr
<llvm::raw_fd_ostream
> indexFile
;
56 llvm::DenseSet
<StringRef
> thinIndices
;