22 "llvm_orc_unregisterVTuneImpl";
24 "llvm_orc_test_registerVTuneImpl";
28 std::unique_ptr<DWARFContext> DC;
33 EmitDebugInfo =
false;
35 DC = std::move(EDC->first);
36 DCBacking = std::move(EDC->second);
42 auto [
I, Inserted] = Deduplicator.try_emplace(S);
44 Batch.
Strings.push_back(S.str());
49 for (
auto Sym :
G.defined_symbols()) {
54 auto &Method = Batch.
Methods.back();
60 Method.ClassFileSI = 0;
61 Method.SourceFileSI = 0;
72 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
73 Method.SourceFileSI = Batch.
Strings.size();
75 DC->getLineInfoForAddress(SAddr).value_or(
DILineInfo()).FileName);
76 for (
auto &LInfo : LinesInfo) {
77 Method.LineTable.push_back(
91 if (Batch.Methods.empty()) {
95 std::lock_guard<std::mutex> Lock(PluginMutex);
96 uint64_t Allocated = Batch.Methods.size();
98 NextMethodID += Allocated;
99 for (
size_t i = Start; i < NextMethodID; ++i) {
100 Batch.Methods[i - Start].MethodID = i;
102 this->PendingMethodIDs[MR] = {Start, Allocated};
104 G.allocActions().push_back(
107 RegisterVTuneImplAddr, Batch)),
115 std::lock_guard<std::mutex> Lock(PluginMutex);
116 auto I = PendingMethodIDs.find(MR);
117 if (I == PendingMethodIDs.end())
120 LoadedMethodIDs[K].push_back(I->second);
121 PendingMethodIDs.erase(I);
129 std::lock_guard<std::mutex> Lock(PluginMutex);
130 PendingMethodIDs.erase(&MR);
136 if (!UnregisterVTuneImplAddr) {
141 std::lock_guard<std::mutex> Lock(PluginMutex);
142 auto I = LoadedMethodIDs.find(K);
143 if (
I == LoadedMethodIDs.end())
146 UnloadedIDs = std::move(
I->second);
147 LoadedMethodIDs.erase(
I);
150 UnregisterVTuneImplAddr, UnloadedIDs))
159 std::lock_guard<std::mutex> Lock(PluginMutex);
160 auto I = LoadedMethodIDs.find(SrcKey);
161 if (
I == LoadedMethodIDs.end())
164 auto &Dest = LoadedMethodIDs[DstKey];
166 LoadedMethodIDs.erase(SrcKey);
171 bool EmitDebugInfo,
bool TestMode) {
173 auto RegisterImplName =
179 return Res.takeError();
181 Res->find(RegisterImplName)->second.getAddress());
183 Res->find(UnregisterImplName)->second.getAddress());
184 return std::make_unique<VTuneSupportPlugin>(
185 EPC, RegisterImplAddr, UnregisterImplAddr, EmitDebugInfo);
static constexpr StringRef RegisterVTuneImplName
static constexpr StringRef RegisterTestVTuneImplName
static constexpr StringRef UnregisterVTuneImplName
static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Represents an object file section.
SectionOrdinal getOrdinal() const
Returns the ordinal for this section.
bool isCallable() const
Returns true is this symbol is callable.
const orc::SymbolStringPtr & getName() const
Returns the name of this symbol (empty if the symbol is anonymous).
orc::ExecutorAddr getAddress() const
Returns the address of this symbol.
Section & getSection() const
Return the Section for this Symbol (Symbol must be defined).
orc::ExecutorAddrDiff getSize() const
Returns the size of this symbol.
orc::ExecutorAddrDiff getOffset() const
Returns the offset for this symbol within the underlying addressable.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
ExecutionSession & getExecutionSession()
Return the ExecutionSession associated with this instance.
Represents a JIT'd dynamic library.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Error withResourceKeyDo(Func &&F) const
Runs the given callback under the session lock, passing in the associated ResourceKey.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, ResourceKey SrcKey) override
static Expected< std::unique_ptr< VTuneSupportPlugin > > Create(ExecutorProcessControl &EPC, JITDylib &JD, bool EmitDebugInfo, bool TestMode=false)
Error notifyEmitted(MaterializationResponsibility &MR) override
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &Config) override
Error notifyFailed(MaterializationResponsibility &MR) override
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override
A utility class for serializing to a blob from a variadic list.
SPS tag type for sequences.
static Expected< WrapperFunctionCall > Create(ExecutorAddr FnAddr, const ArgTs &...Args)
Create a WrapperFunctionCall using the given SPS serializer to serialize the arguments.
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
LLVM_ABI Expected< std::pair< std::unique_ptr< DWARFContext >, StringMap< std::unique_ptr< MemoryBuffer > > > > createDWARFContext(jitlink::LinkGraph &G)
This is an optimization pass for GlobalISel generic memory operations.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
A format-neutral container for source line information.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...