LLVM  4.0.0
ModuleSummaryIndexObjectFile.h
Go to the documentation of this file.
1 //===- ModuleSummaryIndexObjectFile.h - Summary index file implementation -=//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the ModuleSummaryIndexObjectFile template class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECT_MODULESUMMARYINDEXOBJECTFILE_H
15 #define LLVM_OBJECT_MODULESUMMARYINDEXOBJECTFILE_H
16 
17 #include "llvm/IR/DiagnosticInfo.h"
19 
20 namespace llvm {
21 class ModuleSummaryIndex;
22 class Module;
23 
24 namespace object {
25 class ObjectFile;
26 
27 /// This class is used to read just the module summary index related
28 /// sections out of the given object (which may contain a single module's
29 /// bitcode or be a combined index bitcode file). It builds a ModuleSummaryIndex
30 /// object.
32  std::unique_ptr<ModuleSummaryIndex> Index;
33 
34 public:
36  std::unique_ptr<ModuleSummaryIndex> I);
38 
39  // TODO: Walk through GlobalValueMap entries for symbols.
40  // However, currently these interfaces are not used by any consumers.
41  void moveSymbolNext(DataRefImpl &Symb) const override {
42  llvm_unreachable("not implemented");
43  }
44  std::error_code printSymbolName(raw_ostream &OS,
45  DataRefImpl Symb) const override {
46  llvm_unreachable("not implemented");
47  return std::error_code();
48  }
49  uint32_t getSymbolFlags(DataRefImpl Symb) const override {
50  llvm_unreachable("not implemented");
51  return 0;
52  }
54  llvm_unreachable("not implemented");
56  }
57  basic_symbol_iterator symbol_end() const override {
58  llvm_unreachable("not implemented");
60  }
61 
62  const ModuleSummaryIndex &getIndex() const {
63  return const_cast<ModuleSummaryIndexObjectFile *>(this)->getIndex();
64  }
65  ModuleSummaryIndex &getIndex() { return *Index; }
66  std::unique_ptr<ModuleSummaryIndex> takeIndex();
67 
68  static inline bool classof(const Binary *v) {
69  return v->isModuleSummaryIndex();
70  }
71 
72  /// \brief Finds and returns bitcode embedded in the given object file, or an
73  /// error code if not found.
75 
76  /// \brief Finds and returns bitcode in the given memory buffer (which may
77  /// be either a bitcode file or a native object file with embedded bitcode),
78  /// or an error code if not found.
81 
82  /// \brief Parse module summary index in the given memory buffer.
83  /// Return new ModuleSummaryIndexObjectFile instance containing parsed module
84  /// summary/index.
86  create(MemoryBufferRef Object);
87 };
88 }
89 
90 /// Parse the module summary index out of an IR file and return the module
91 /// summary index object if found, or nullptr if not.
92 Expected<std::unique_ptr<ModuleSummaryIndex>>
93 getModuleSummaryIndexForFile(StringRef Path);
94 }
95 
96 #endif
static ErrorOr< MemoryBufferRef > findBitcodeInMemBuffer(MemoryBufferRef Object)
Finds and returns bitcode in the given memory buffer (which may be either a bitcode file or a native ...
Represents either an error or a value T.
Definition: ErrorOr.h:68
basic_symbol_iterator symbol_begin() const override
static Expected< std::unique_ptr< ModuleSummaryIndexObjectFile > > create(MemoryBufferRef Object)
Parse module summary index in the given memory buffer.
bool isModuleSummaryIndex() const
Definition: Binary.h:130
This class is the base class for all object file types.
Definition: ObjectFile.h:178
static ErrorOr< MemoryBufferRef > findBitcodeInObject(const ObjectFile &Obj)
Finds and returns bitcode embedded in the given object file, or an error code if not found...
Tagged union holding either a T or a Error.
void moveSymbolNext(DataRefImpl &Symb) const override
Class to hold module path string table and global value map, and encapsulate methods for operating on...
ModuleSummaryIndexObjectFile(MemoryBufferRef Object, std::unique_ptr< ModuleSummaryIndex > I)
std::error_code printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndexForFile(StringRef Path)
Parse the module summary index out of an IR file and return the module summary index object if found...
content_iterator< BasicSymbolRef > basic_symbol_iterator
Definition: SymbolicFile.h:126
std::unique_ptr< ModuleSummaryIndex > takeIndex()
#define I(x, y, z)
Definition: MD5.cpp:54
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: SymbolicFile.h:86
uint32_t getSymbolFlags(DataRefImpl Symb) const override
This class is used to read just the module summary index related sections out of the given object (wh...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
basic_symbol_iterator symbol_end() const override