17#define DEBUG_TYPE "orc"
24 assert(!
I.InitSymbol &&
"I already has an init symbol");
28 std::string InitSymString;
30 <<
"$." << ObjFileName <<
".__inits." << Counter++;
31 I.InitSymbol = ES.
intern(InitSymString);
32 }
while (
I.SymbolFlags.count(
I.InitSymbol));
57 if (
auto SymType =
Sym.getType()) {
61 return SymType.takeError();
65 return Name.takeError();
68 return SymFlags.takeError();
71 if (
Name->starts_with(
"l"))
74 I.SymbolFlags[ES.
intern(*
Name)] = std::move(*SymFlags);
114 if (
auto SymType =
Sym.getType()) {
118 return SymType.takeError();
122 return Name.takeError();
126 return SymFlags.takeError();
132 I.SymbolFlags[ES.
intern(std::move(*
Name))] = std::move(*SymFlags);
137 if (
auto SecName = Sec.getName()) {
152 std::vector<std::optional<object::coff_aux_section_definition>> ComdatDefs(
163 if (
auto *Def = COFFSym.getSectionDefinition()) {
164 auto Sec = Obj.
getSection(COFFSym.getSectionNumber());
166 return Sec.takeError();
169 ComdatDefs[COFFSym.getSectionNumber()] = *Def;
174 ComdatDefs[COFFSym.getSectionNumber()]) {
175 auto Def = ComdatDefs[COFFSym.getSectionNumber()];
179 ComdatDefs[COFFSym.getSectionNumber()] = std::nullopt;
191 if (
auto SymType =
Sym.getType()) {
195 return SymType.takeError();
199 return Name.takeError();
203 return SymFlags.takeError();
207 if (COFFSym.isWeakExternal())
213 I.SymbolFlags[ES.
intern(*
Name)] = std::move(*SymFlags);
218 if (
auto SecName = Sec.getName()) {
224 return SecName.takeError();
250 if (
auto SymType =
Sym.getType()) {
254 return SymType.takeError();
258 return Name.takeError();
262 return SymFlags.takeError();
264 I.SymbolFlags[ES.
intern(*
Name)] = std::move(*SymFlags);
275 return Obj.takeError();
277 if (
auto *MachOObj = dyn_cast<object::MachOObjectFile>(Obj->get()))
279 else if (
auto *ELFObj = dyn_cast<object::ELFObjectFileBase>(Obj->get()))
281 else if (
auto *COFFObj = dyn_cast<object::COFFObjectFile>(Obj->get()))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
Flags for symbols in the JIT.
static Expected< JITSymbolFlags > fromObjectSymbol(const object::SymbolRef &Symbol)
Construct a JITSymbolFlags value based on the flags of the given libobject symbol.
@ MaterializationSideEffectsOnly
StringRef - Represent a constant reference to a string, i.e.
StringRef getFileName() const
uint32_t getNumberOfSections() const
Expected< const coff_section * > getSection(int32_t index) const
COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const
elf_symbol_iterator_range symbols() const
unsigned getSectionType(SectionRef Sec) const
StringRef getSectionFinalSegmentName(DataRefImpl Sec) const
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
This class is the base class for all object file types.
section_iterator_range sections() const
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
symbol_iterator_range symbols() const
An ExecutionSession represents a running JIT program.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Pointer to a pooled string representing a symbol name.
A raw_ostream that writes to an std::string.
@ IMAGE_COMDAT_SELECT_NODUPLICATES
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
bool isReservedSectionNumber(int32_t SectionNumber)
@ S_MOD_INIT_FUNC_POINTERS
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
void addInitSymbol(MaterializationUnit::Interface &I, ExecutionSession &ES, StringRef ObjFileName)
Adds an initializer symbol to the given MU interface.
static Expected< MaterializationUnit::Interface > getMachOObjectFileSymbolInfo(ExecutionSession &ES, const object::MachOObjectFile &Obj)
Expected< MaterializationUnit::Interface > getGenericObjectFileSymbolInfo(ExecutionSession &ES, const object::ObjectFile &Obj)
static Expected< MaterializationUnit::Interface > getELFObjectFileSymbolInfo(ExecutionSession &ES, const object::ELFObjectFileBase &Obj)
bool isMachOInitializerSection(StringRef SegName, StringRef SecName)
Expected< MaterializationUnit::Interface > getObjectFileInterface(ExecutionSession &ES, MemoryBufferRef ObjBuffer)
Returns a MaterializationUnit::Interface for the object file contained in the given buffer,...
bool isCOFFInitializerSection(StringRef Name)
static Expected< MaterializationUnit::Interface > getCOFFObjectFileSymbolInfo(ExecutionSession &ES, const object::COFFObjectFile &Obj)
bool isELFInitializerSection(StringRef SecName)
This is an optimization pass for GlobalISel generic memory operations.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.