Path: blob/main/contrib/llvm-project/lld/ELF/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 ELF9// file by compiling them using LLVM.10//11// If LTO is in use, your input files are not in regular ELF 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// an ELF file that contains native code. This file provides that15// functionality.16//17//===----------------------------------------------------------------------===//1819#ifndef LLD_ELF_LTO_H20#define LLD_ELF_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 {30class LTO;31}3233namespace lld::elf {3435class BitcodeFile;36class InputFile;3738class BitcodeCompiler {39public:40BitcodeCompiler();41~BitcodeCompiler();4243void add(BitcodeFile &f);44std::vector<InputFile *> compile();4546private:47std::unique_ptr<llvm::lto::LTO> ltoObj;48// An array of (module name, native relocatable file content) pairs.49SmallVector<std::pair<std::string, SmallString<0>>, 0> buf;50std::vector<std::unique_ptr<MemoryBuffer>> files;51SmallVector<std::string, 0> filenames;52llvm::DenseSet<StringRef> usedStartStop;53std::unique_ptr<llvm::raw_fd_ostream> indexFile;54llvm::DenseSet<StringRef> thinIndices;55};56} // namespace lld::elf5758#endif596061