1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/include/llvm/Object/ModuleSummaryIndexObjectFile.h
Teresa Johnson 89e5e1dadb [ThinLTO] Renaming of function index to module summary index (NFC)
(Resubmitting after fixing missing file issue)

With the changes in r263275, there are now more than just functions in
the summary. Completed the renaming of data structures (started in
r263275) to reflect the wider scope. In particular, changed the
FunctionIndex* data structures to ModuleIndex*, and renamed related
variables and comments. Also renamed the files to reflect the changes.

A companion clang patch will immediately succeed this patch to reflect
this renaming.

llvm-svn: 263513
2016-03-15 00:04:37 +00:00

113 lines
4.2 KiB
C++

//===- ModuleSummaryIndexObjectFile.h - Summary index file implementation -=//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the ModuleSummaryIndexObjectFile template class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_OBJECT_MODULESUMMARYINDEXOBJECTFILE_H
#define LLVM_OBJECT_MODULESUMMARYINDEXOBJECTFILE_H
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/Object/SymbolicFile.h"
namespace llvm {
class ModuleSummaryIndex;
class Module;
namespace object {
class ObjectFile;
/// This class is used to read just the module summary index related
/// sections out of the given object (which may contain a single module's
/// bitcode or be a combined index bitcode file). It builds a ModuleSummaryIndex
/// object.
class ModuleSummaryIndexObjectFile : public SymbolicFile {
std::unique_ptr<ModuleSummaryIndex> Index;
public:
ModuleSummaryIndexObjectFile(MemoryBufferRef Object,
std::unique_ptr<ModuleSummaryIndex> I);
~ModuleSummaryIndexObjectFile() override;
// TODO: Walk through GlobalValueMap entries for symbols.
// However, currently these interfaces are not used by any consumers.
void moveSymbolNext(DataRefImpl &Symb) const override {
llvm_unreachable("not implemented");
}
std::error_code printSymbolName(raw_ostream &OS,
DataRefImpl Symb) const override {
llvm_unreachable("not implemented");
return std::error_code();
}
uint32_t getSymbolFlags(DataRefImpl Symb) const override {
llvm_unreachable("not implemented");
return 0;
}
basic_symbol_iterator symbol_begin_impl() const override {
llvm_unreachable("not implemented");
return basic_symbol_iterator(BasicSymbolRef());
}
basic_symbol_iterator symbol_end_impl() const override {
llvm_unreachable("not implemented");
return basic_symbol_iterator(BasicSymbolRef());
}
const ModuleSummaryIndex &getIndex() const {
return const_cast<ModuleSummaryIndexObjectFile *>(this)->getIndex();
}
ModuleSummaryIndex &getIndex() { return *Index; }
std::unique_ptr<ModuleSummaryIndex> takeIndex();
static inline bool classof(const Binary *v) {
return v->isModuleSummaryIndex();
}
/// \brief Finds and returns bitcode embedded in the given object file, or an
/// error code if not found.
static ErrorOr<MemoryBufferRef> findBitcodeInObject(const ObjectFile &Obj);
/// \brief Finds and returns bitcode in the given memory buffer (which may
/// be either a bitcode file or a native object file with embedded bitcode),
/// or an error code if not found.
static ErrorOr<MemoryBufferRef>
findBitcodeInMemBuffer(MemoryBufferRef Object);
/// \brief Looks for summary sections in the given memory buffer,
/// returns true if found, else false.
static bool
hasGlobalValueSummaryInMemBuffer(MemoryBufferRef Object,
DiagnosticHandlerFunction DiagnosticHandler);
/// \brief Parse module summary index in the given memory buffer.
/// Return new ModuleSummaryIndexObjectFile instance containing parsed module
/// summary/index.
static ErrorOr<std::unique_ptr<ModuleSummaryIndexObjectFile>>
create(MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,
bool IsLazy = false);
/// \brief Parse the summary information for global value with the
/// given name out of the given buffer. Parsed information is
/// stored on the index object saved in this object.
std::error_code
findGlobalValueSummaryInMemBuffer(MemoryBufferRef Object,
DiagnosticHandlerFunction DiagnosticHandler,
StringRef ValueName);
};
}
/// Parse the module summary index out of an IR file and return the module
/// summary index object if found, or nullptr if not.
ErrorOr<std::unique_ptr<ModuleSummaryIndex>>
getModuleSummaryIndexForFile(StringRef Path,
DiagnosticHandlerFunction DiagnosticHandler);
}
#endif