LLVM: lib/ExecutionEngine/Orc/LinkGraphLayer.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
10
14
15#define DEBUG_TYPE "orc"
16
17using namespace llvm;
20
21namespace {
22
23bool hasInitializerSection(LinkGraph &G) {
24 bool IsMachO = G.getTargetTriple().isOSBinFormatMachO();
25 bool IsElf = G.getTargetTriple().isOSBinFormatELF();
26 if (!IsMachO && !IsElf)
27 return false;
28
29 for (auto &Sec : G.sections()) {
31 return true;
33 return true;
34 }
35
36 return false;
37}
38
39}
40
42
44
46
48
49 auto AddSymbol = [&](Symbol *Sym) {
50
52 return;
53 assert(Sym->hasName() && "Anonymous non-local symbol?");
54
56 };
57
58 for (auto *Sym : G.defined_symbols())
59 AddSymbol(Sym);
60 for (auto *Sym : G.absolute_symbols())
61 AddSymbol(Sym);
62
63 if (hasInitializerSection(G)) {
64 std::string InitSymString;
65 {
67 << "$." << G.getName() << ".__inits" << Counter++;
68 }
69 LGI.InitSymbol = ES.intern(InitSymString);
70 }
71
72 return LGI;
73}
74
77
80
85
88
89 return Flags;
90}
91
93
94void LinkGraphMaterializationUnit::discard(const JITDylib &JD,
96 for (auto *Sym : G->defined_symbols())
97 if (Sym->getName() == Name) {
99 "Discarding non-weak definition");
100 G->makeExternal(*Sym);
101 break;
102 }
103}
104
105}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Flags for symbols in the JIT.
@ MaterializationSideEffectsOnly
StringRef - Represent a constant reference to a string, i.e.
bool isCallable() const
Returns true is this symbol is callable.
Scope getScope() const
Get the visibility for this Symbol.
Linkage getLinkage() const
Get the linkage for this Symbol.
Represents a JIT'd dynamic library.
MaterializationUnit::Interface getInterface(jitlink::LinkGraph &G)
Get the interface for the given LinkGraph.
Definition LinkGraphLayer.cpp:45
static JITSymbolFlags getJITSymbolFlagsForSymbol(jitlink::Symbol &Sym)
Get the JITSymbolFlags for the given symbol.
Definition LinkGraphLayer.cpp:75
virtual ~LinkGraphLayer()
StringRef getName() const override
Return the name of this materialization unit.
Definition LinkGraphLayer.cpp:92
Pointer to a pooled string representing a symbol name.
A raw_ostream that writes to an std::string.
LLVM_ABI bool isMachOInitializerSection(StringRef SegName, StringRef SecName)
LLVM_ABI bool isELFInitializerSection(StringRef SecName)
This is an optimization pass for GlobalISel generic memory operations.
SymbolFlagsMap SymbolFlags
SymbolStringPtr InitSymbol