File: ModuleSummaryIndexObjectFile.h

package info (click to toggle)
llvm-toolchain-4.0 1%3A4.0.1-10~deb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 493,332 kB
  • sloc: cpp: 2,698,100; ansic: 552,773; asm: 128,821; python: 121,589; objc: 105,054; sh: 21,174; lisp: 6,758; ml: 5,532; perl: 5,311; pascal: 5,245; makefile: 2,083; cs: 1,868; xml: 686; php: 212; csh: 117
file content (96 lines) | stat: -rw-r--r-- 3,439 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//===- 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() const override {
    llvm_unreachable("not implemented");
    return basic_symbol_iterator(BasicSymbolRef());
  }
  basic_symbol_iterator symbol_end() 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 Parse module summary index in the given memory buffer.
  /// Return new ModuleSummaryIndexObjectFile instance containing parsed module
  /// summary/index.
  static Expected<std::unique_ptr<ModuleSummaryIndexObjectFile>>
  create(MemoryBufferRef Object);
};
}

/// Parse the module summary index out of an IR file and return the module
/// summary index object if found, or nullptr if not.
Expected<std::unique_ptr<ModuleSummaryIndex>>
getModuleSummaryIndexForFile(StringRef Path);
}

#endif