LLVM: lib/Object/ModuleSymbolTable.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
44#include
45#include
46#include
47#include
48
49using namespace llvm;
50using namespace object;
51
53 if (FirstMod)
54 assert(FirstMod->getTargetTriple() == M->getTargetTriple());
55 else
56 FirstMod = M;
57
58 for (GlobalValue &GV : M->global_values())
59 SymTab.push_back(&GV);
60
62 SymTab.push_back(new (AsmSymbols.Allocate())
63 AsmSymbol(std::string(Name), Flags));
64 });
65}
66
67static void
70
71
72
73 if (M.getContext().getDiagHandlerPtr()->HasErrors)
74 return;
77 return;
78
79 std::string Err;
80 const Triple TT(M.getTargetTriple());
82 assert(T && T->hasMCAsmParser());
83
84 std::unique_ptr MRI(T->createMCRegInfo(TT));
86 return;
87
89 std::unique_ptr MAI(T->createMCAsmInfo(*MRI, TT, MCOptions));
90 if (!MAI)
91 return;
92
93 std::unique_ptr STI(T->createMCSubtargetInfo(TT, "", ""));
94 if (!STI)
95 return;
96
97 std::unique_ptr MCII(T->createMCInstrInfo());
98 if (!MCII)
99 return;
100
101 std::unique_ptr Buffer(
104 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
105
107 std::unique_ptr MOFI(
108 T->createMCObjectFileInfo(MCCtx, false));
111 T->createNullTargetStreamer(Streamer);
112
113 std::unique_ptr Parser(
115
116 std::unique_ptr TAP(
117 T->createMCAsmParser(*STI, *Parser, *MCII, MCOptions));
118 if (!TAP)
119 return;
120
123 std::vector<const MDNode *> &LocInfos) {
124 M.getContext().diagnose(
126 });
127
128
129
131
132 Parser->setTargetParser(*TAP);
133 if (Parser->Run(false))
134 return;
135
136 Init(Streamer);
137}
138
144
145 for (auto &KV : Streamer) {
148
152 llvm_unreachable("NeverSeen should have been replaced earlier");
155 break;
157 break;
162 break;
166 break;
170 }
172 }
173 });
174
175
176
177
178 Triple TT(M.getTargetTriple());
179 if (!TT.isOSBinFormatELF() || !TT.isX86())
180 return;
181 auto CM = M.getCodeModel();
184 AsmSymbol("_GLOBAL_OFFSET_TABLE_",
187 }
188}
189
194 for (auto &Alias : KV.second)
195 AsmSymver(KV.first->getName(), Alias);
196 });
197}
198
201 OS << cast<AsmSymbol *>(S)->first;
202 return;
203 }
204
206 if (GV->hasDLLImportStorageClass())
207 OS << "__imp_";
208
209 Mang.getNameWithPrefix(OS, GV, false);
210}
211
215
217
219 if (GV->isDeclarationForLinker())
221 else if (GV->hasHiddenVisibility() && !GV->hasLocalLinkage())
224 if (GVar->isConstant())
226 }
232 if (GV->hasPrivateLinkage())
234 if (!GV->hasLocalLinkage())
236 if (GV->hasCommonLinkage())
238 if (GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() ||
239 GV->hasExternalWeakLinkage())
241
242 if (GV->getName().starts_with("llvm."))
245 if (Var->getSection() == "llvm.metadata")
247 }
248
249 return Res;
250}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Module.h This file contains the declarations for the Module class.
static void initializeRecordStreamer(const Module &M, function_ref< void(RecordStreamer &)> Init)
Definition ModuleSymbolTable.cpp:68
Diagnostic information for SMDiagnostic reporting.
LLVM_ABI const GlobalObject * getAliaseeObject() const
Context object for machine code objects.
void setObjectFileInfo(const MCObjectFileInfo *Mofi)
void setDiagnosticHandler(DiagHandlerTy DiagHandler)
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
LLVM_ABI void addModule(Module *M)
Definition ModuleSymbolTable.cpp:52
static LLVM_ABI 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:190
std::pair< std::string, uint32_t > AsmSymbol
LLVM_ABI void printSymbolName(raw_ostream &OS, Symbol S) const
Definition ModuleSymbolTable.cpp:199
PointerUnion< GlobalValue *, AsmSymbol * > Symbol
LLVM_ABI uint32_t getSymbolFlags(Symbol S) const
Definition ModuleSymbolTable.cpp:212
static LLVM_ABI 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:139
A Module instance is used to store all the information related to an LLVM module.
iterator_range< const_symver_iterator > symverAliases()
void flushSymverDirectives()
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Represents a location in source code.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI MCAsmParser * createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &, const MCAsmInfo &, unsigned CB=0)
Create an MCAsmParser instance for parsing assembly similar to gas syntax.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
static const Target * lookupTarget(StringRef TripleStr, std::string &Error)
lookupTarget - Lookup a target based on a target triple.