brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · acf3bcf Raw
61 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file provides a way to combine bitcode files into one ELF10// file by compiling them using LLVM.11//12// If LTO is in use, your input files are not in regular ELF files13// but instead LLVM bitcode files. In that case, the linker has to14// convert bitcode files into the native format so that we can create15// an ELF file that contains native code. This file provides that16// functionality.17//18//===----------------------------------------------------------------------===//19 20#ifndef LLD_ELF_LTO_H21#define LLD_ELF_LTO_H22 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 30namespace llvm::lto {31class LTO;32}33 34namespace lld::elf {35struct Ctx;36class BitcodeFile;37class InputFile;38 39class BitcodeCompiler {40public:41  BitcodeCompiler(Ctx &ctx);42  ~BitcodeCompiler();43 44  void add(BitcodeFile &f);45  SmallVector<std::unique_ptr<InputFile>, 0> compile();46 47private:48  Ctx &ctx;49  std::unique_ptr<llvm::lto::LTO> ltoObj;50  // An array of (module name, native relocatable file content) pairs.51  SmallVector<std::pair<std::string, SmallString<0>>, 0> buf;52  std::vector<std::unique_ptr<MemoryBuffer>> files;53  SmallVector<std::string, 0> filenames;54  llvm::DenseSet<StringRef> usedStartStop;55  std::unique_ptr<llvm::raw_fd_ostream> indexFile;56  llvm::DenseSet<StringRef> thinIndices;57};58} // namespace lld::elf59 60#endif61