Path: blob/main/contrib/llvm-project/lld/COFF/LTO.h
34870 views
//===- LTO.h ----------------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file provides a way to combine bitcode files into one COFF9// file by compiling them using LLVM.10//11// If LTO is in use, your input files are not in regular COFF files12// but instead LLVM bitcode files. In that case, the linker has to13// convert bitcode files into the native format so that we can create14// a COFF file that contains native code. This file provides that15// functionality.16//17//===----------------------------------------------------------------------===//1819#ifndef LLD_COFF_LTO_H20#define LLD_COFF_LTO_H2122#include "lld/Common/LLVM.h"23#include "llvm/ADT/DenseSet.h"24#include "llvm/ADT/SmallString.h"25#include "llvm/Support/raw_ostream.h"26#include <memory>27#include <vector>2829namespace llvm::lto {30struct Config;31class LTO;32}3334namespace lld::coff {3536class BitcodeFile;37class InputFile;38class COFFLinkerContext;3940class BitcodeCompiler {41public:42BitcodeCompiler(COFFLinkerContext &ctx);43~BitcodeCompiler();4445void add(BitcodeFile &f);46std::vector<InputFile *> compile();4748private:49std::unique_ptr<llvm::lto::LTO> ltoObj;50std::vector<std::pair<std::string, SmallString<0>>> buf;51std::vector<std::unique_ptr<MemoryBuffer>> files;52std::vector<std::string> file_names;53std::unique_ptr<llvm::raw_fd_ostream> indexFile;54llvm::DenseSet<StringRef> thinIndices;5556std::string getThinLTOOutputFile(StringRef path);57llvm::lto::Config createConfig();5859COFFLinkerContext &ctx;60};61}6263#endif646566