2016-03-23 04:52:10 +08:00
|
|
|
//===- LTO.h ----------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-03-23 04:52:10 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides a way to combine bitcode files into one ELF
|
|
|
|
// file by compiling them using LLVM.
|
|
|
|
//
|
|
|
|
// If LTO is in use, your input files are not in regular ELF files
|
|
|
|
// but instead LLVM bitcode files. In that case, the linker has to
|
|
|
|
// convert bitcode files into the native format so that we can create
|
|
|
|
// an ELF file that contains native code. This file provides that
|
|
|
|
// functionality.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_LTO_H
|
|
|
|
#define LLD_ELF_LTO_H
|
|
|
|
|
2017-10-03 05:00:41 +08:00
|
|
|
#include "lld/Common/LLVM.h"
|
2017-07-27 07:39:10 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2016-03-23 04:52:10 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2018-05-03 05:40:07 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2016-09-29 09:59:03 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
2016-03-23 04:52:10 +08:00
|
|
|
|
2016-09-29 08:40:08 +08:00
|
|
|
namespace llvm {
|
|
|
|
namespace lto {
|
|
|
|
class LTO;
|
|
|
|
}
|
2017-07-18 19:55:35 +08:00
|
|
|
} // namespace llvm
|
2016-09-29 08:40:08 +08:00
|
|
|
|
2016-03-23 04:52:10 +08:00
|
|
|
namespace lld {
|
|
|
|
namespace elf {
|
|
|
|
|
|
|
|
class BitcodeFile;
|
2016-03-30 03:08:46 +08:00
|
|
|
class InputFile;
|
2018-05-03 05:40:07 +08:00
|
|
|
class LazyObjFile;
|
2016-03-23 04:52:10 +08:00
|
|
|
|
|
|
|
class BitcodeCompiler {
|
|
|
|
public:
|
2016-04-23 05:16:18 +08:00
|
|
|
BitcodeCompiler();
|
2016-09-29 08:40:08 +08:00
|
|
|
~BitcodeCompiler();
|
2016-09-30 06:37:45 +08:00
|
|
|
|
2017-02-01 18:26:03 +08:00
|
|
|
void add(BitcodeFile &f);
|
2016-09-14 08:05:51 +08:00
|
|
|
std::vector<InputFile *> compile();
|
2016-03-23 04:52:10 +08:00
|
|
|
|
2016-09-29 08:40:08 +08:00
|
|
|
private:
|
2016-11-26 13:37:04 +08:00
|
|
|
std::unique_ptr<llvm::lto::LTO> ltoObj;
|
2018-05-18 02:27:12 +08:00
|
|
|
std::vector<SmallString<0>> buf;
|
2017-03-02 07:00:10 +08:00
|
|
|
std::vector<std::unique_ptr<MemoryBuffer>> files;
|
2017-07-27 07:39:10 +08:00
|
|
|
llvm::DenseSet<StringRef> usedStartStop;
|
2018-05-08 01:46:28 +08:00
|
|
|
std::unique_ptr<llvm::raw_fd_ostream> indexFile;
|
2018-09-11 22:37:27 +08:00
|
|
|
llvm::DenseSet<StringRef> thinIndices;
|
2016-03-23 04:52:10 +08:00
|
|
|
};
|
2017-07-18 19:55:35 +08:00
|
|
|
} // namespace elf
|
|
|
|
} // namespace lld
|
2016-03-23 04:52:10 +08:00
|
|
|
|
|
|
|
#endif
|