LLVM  14.0.0git
ModuleSymbolTable.h
Go to the documentation of this file.
1 //===- ModuleSymbolTable.h - symbol table for in-memory IR ------*- 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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This class represents a symbol table built from in-memory IR. It provides
10 // access to GlobalValues and should only be used if such access is required
11 // (e.g. in the LTO implementation).
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_OBJECT_MODULESYMBOLTABLE_H
16 #define LLVM_OBJECT_MODULESYMBOLTABLE_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/PointerUnion.h"
20 #include "llvm/IR/Mangler.h"
22 #include "llvm/Support/Allocator.h"
23 #include <cstdint>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 namespace llvm {
29 
30 class GlobalValue;
31 class Module;
32 
34 public:
35  using AsmSymbol = std::pair<std::string, uint32_t>;
37 
38 private:
39  Module *FirstMod = nullptr;
40 
42  std::vector<Symbol> SymTab;
43  Mangler Mang;
44 
45 public:
46  ArrayRef<Symbol> symbols() const { return SymTab; }
47  void addModule(Module *M);
48 
49  void printSymbolName(raw_ostream &OS, Symbol S) const;
51 
52  /// Parse inline ASM and collect the symbols that are defined or referenced in
53  /// the current module.
54  ///
55  /// For each found symbol, call \p AsmSymbol with the name of the symbol found
56  /// and the associated flags.
57  static void CollectAsmSymbols(
58  const Module &M,
60 
61  /// Parse inline ASM and collect the symvers directives that are defined in
62  /// the current module.
63  ///
64  /// For each found symbol, call \p AsmSymver with the name of the symbol and
65  /// its alias.
66  static void
67  CollectAsmSymvers(const Module &M,
68  function_ref<void(StringRef, StringRef)> AsmSymver);
69 };
70 
71 } // end namespace llvm
72 
73 #endif // LLVM_OBJECT_MODULESYMBOLTABLE_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::ModuleSymbolTable::AsmSymbol
std::pair< std::string, uint32_t > AsmSymbol
Definition: ModuleSymbolTable.h:35
llvm::ModuleSymbolTable::Symbol
PointerUnion< GlobalValue *, AsmSymbol * > Symbol
Definition: ModuleSymbolTable.h:36
Allocator.h
llvm::SpecificBumpPtrAllocator< AsmSymbol >
llvm::object::BasicSymbolRef::Flags
Flags
Definition: SymbolicFile.h:106
SymbolicFile.h
llvm::Mangler
Definition: Mangler.h:27
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::ModuleSymbolTable::printSymbolName
void printSymbolName(raw_ostream &OS, Symbol S) const
Definition: ModuleSymbolTable.cpp:179
llvm::ModuleSymbolTable::symbols
ArrayRef< Symbol > symbols() const
Definition: ModuleSymbolTable.h:46
llvm::ModuleSymbolTable::addModule
void addModule(Module *M)
Definition: ModuleSymbolTable.cpp:57
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
ArrayRef.h
PointerUnion.h
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
Mangler.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
uint32_t
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:119
llvm::ModuleSymbolTable::getSymbolFlags
uint32_t getSymbolFlags(Symbol S) const
Definition: ModuleSymbolTable.cpp:192
llvm::ModuleSymbolTable::CollectAsmSymvers
static void CollectAsmSymvers(const Module &M, function_ref< void(StringRef, StringRef)> AsmSymver)
Parse inline ASM and collect the symvers directives that are defined in the current module.
Definition: ModuleSymbolTable.cpp:170
llvm::ModuleSymbolTable
Definition: ModuleSymbolTable.h:33
llvm::ModuleSymbolTable::CollectAsmSymbols
static void CollectAsmSymbols(const Module &M, function_ref< void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol)
Parse inline ASM and collect the symbols that are defined or referenced in the current module.
Definition: ModuleSymbolTable.cpp:133