23 "llvm_orc_unregisterVTuneImpl";
25 "llvm_orc_test_registerVTuneImpl";
41 : EPC(EPC), RegisterVTuneImplAddr(RegisterImplAddr),
45 EmitDebugInfo(EmitDebugInfo) {}
49 std::unique_ptr<DWARFContext> DC;
54 EmitDebugInfo =
false;
56 DC = std::move(EDC->first);
57 DCBacking = std::move(EDC->second);
63 auto [
I, Inserted] = Deduplicator.try_emplace(S);
65 Batch.
Strings.push_back(S.str());
70 for (
auto Sym :
G.defined_symbols()) {
71 if (!Sym->isCallable())
75 auto &Method = Batch.
Methods.back();
78 Method.LoadAddr = Sym->getAddress();
79 Method.LoadSize = Sym->getSize();
80 Method.NameSI = GetStringIdx(*Sym->getName());
81 Method.ClassFileSI = 0;
82 Method.SourceFileSI = 0;
87 auto &
Section = Sym->getSection();
88 auto Addr = Sym->getAddress();
92 SAddr, Sym->getSize(),
94 Method.SourceFileSI = Batch.
Strings.size();
96 DC->getLineInfoForAddress(SAddr).value_or(
DILineInfo()).FileName);
97 for (
auto &LInfo : LinesInfo) {
98 Method.LineTable.push_back(
99 std::pair<unsigned, unsigned>{ Sym->getOffset(),
112 if (Batch.Methods.empty()) {
116 std::lock_guard<std::mutex> Lock(PluginMutex);
117 uint64_t Allocated = Batch.Methods.size();
118 uint64_t Start = NextMethodID;
119 NextMethodID += Allocated;
120 for (
size_t i = Start; i < NextMethodID; ++i) {
121 Batch.Methods[i - Start].MethodID = i;
123 this->PendingMethodIDs[MR] = {Start, Allocated};
125 G.allocActions().push_back(
128 RegisterVTuneImplAddr, Batch)),
136 std::lock_guard<std::mutex> Lock(PluginMutex);
137 auto I = PendingMethodIDs.find(MR);
138 if (I == PendingMethodIDs.end())
141 LoadedMethodIDs[K].push_back(I->second);
142 PendingMethodIDs.erase(I);
150 std::lock_guard<std::mutex> Lock(PluginMutex);
151 PendingMethodIDs.erase(&MR);
157 if (!UnregisterVTuneImpl) {
162 std::lock_guard<std::mutex> Lock(PluginMutex);
163 auto I = LoadedMethodIDs.find(
K);
164 if (
I == LoadedMethodIDs.end())
167 UnloadedIDs = std::move(
I->second);
168 LoadedMethodIDs.erase(
I);
170 if (
auto Err = UnregisterVTuneImpl(EPC.getExecutionSession(), UnloadedIDs))
179 std::lock_guard<std::mutex> Lock(PluginMutex);
180 auto I = LoadedMethodIDs.find(SrcKey);
181 if (
I == LoadedMethodIDs.end())
184 auto &Dest = LoadedMethodIDs[DstKey];
186 LoadedMethodIDs.erase(SrcKey);
191 bool EmitDebugInfo,
bool TestMode) {
192 auto &ES = EPC.getExecutionSession();
193 auto RegisterImplName =
199 return Res.takeError();
201 Res->find(RegisterImplName)->second.getAddress());
203 Res->find(UnregisterImplName)->second.getAddress());
204 return std::make_unique<VTuneSupportPlugin>(
205 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.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
Represents an object file section.
SectionOrdinal getOrdinal() const
Returns the ordinal for this section.
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
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.
A symbol name together with the naming level (SymbolNameKind) it is expressed in, so that a Mangler /...
static constexpr SymbolNameSpec c(StringRef Name)
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)
VTuneSupportPlugin(ExecutorProcessControl &EPC, ExecutorAddr RegisterImplAddr, ExecutorAddr UnregisterImplAddr, bool EmitDebugInfo)
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.
static Expected< WrapperFunctionCall > Create(ExecutorAddr FnAddr, const ArgTs &...Args)
Create a WrapperFunctionCall using the given SPS serializer to serialize the arguments.
SPSSequence< SPSTuple< uint64_t, uint64_t > > SPSVTuneUnloadedMethodIDs
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...
SmallVector< std::pair< uint64_t, uint64_t > > VTuneUnloadedMethodIDs
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.
SmallVector< std::pair< uint64_t, DILineInfo >, 16 > DILineInfoTable
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...
LinkGraphPassList PostFixupPasses
Post-fixup passes.
void(shared::SPSVTuneUnloadedMethodIDs) SPSSig
static constexpr SymbolNameSpec Name