[LoopStrengthReduce] Teach LoopStrengthReduce to preserve MemorySSA is available.
[llvm-project.git] / lld / wasm / LTO.h
blob9c1e1788ed385977c4a728625a9c15081a48c77f
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 wasm
10 // file by compiling them using LLVM.
12 // If LTO is in use, your input files are not in regular wasm 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 wasm file that contains native code. This file provides that
16 // functionality.
18 //===----------------------------------------------------------------------===//
20 #ifndef LLD_WASM_LTO_H
21 #define LLD_WASM_LTO_H
23 #include "lld/Common/LLVM.h"
24 #include "llvm/ADT/SmallString.h"
25 #include "Writer.h"
26 #include <memory>
27 #include <vector>
29 namespace llvm {
30 namespace lto {
31 class LTO;
33 } // namespace llvm
35 namespace lld {
36 namespace wasm {
38 class BitcodeFile;
39 class InputFile;
41 class BitcodeCompiler {
42 public:
43 BitcodeCompiler();
44 ~BitcodeCompiler();
46 void add(BitcodeFile &f);
47 std::vector<StringRef> compile();
49 private:
50 std::unique_ptr<llvm::lto::LTO> ltoObj;
51 std::vector<SmallString<0>> buf;
52 std::vector<std::unique_ptr<MemoryBuffer>> files;
54 } // namespace wasm
55 } // namespace lld
57 #endif