23 "llvm_orc_unregisterVTuneImpl";
25 "llvm_orc_test_registerVTuneImpl";
41 : EPC(EPC), RegisterVTuneImplAddr(RegisterImplAddr),
46 EmitDebugInfo(EmitDebugInfo) {}
50 std::unique_ptr<DWARFContext> DC;
55 EmitDebugInfo =
false;
57 DC = std::move(EDC->first);
58 DCBacking = std::move(EDC->second);
64 auto [
I, Inserted] = Deduplicator.try_emplace(S);
66 Batch.
Strings.push_back(S.str());
71 for (
auto Sym :
G.defined_symbols()) {
72 if (!Sym->isCallable())
76 auto &Method = Batch.
Methods.back();
79 Method.LoadAddr = Sym->getAddress();
80 Method.LoadSize = Sym->getSize();
81 Method.NameSI = GetStringIdx(*Sym->getName());
82 Method.ClassFileSI = 0;
83 Method.SourceFileSI = 0;
88 auto &
Section = Sym->getSection();
89 auto Addr = Sym->getAddress();
93 SAddr, Sym->getSize(),
95 Method.SourceFileSI = Batch.
Strings.size();
97 DC->getLineInfoForAddress(SAddr).value_or(
DILineInfo()).FileName);
98 for (
auto &LInfo : LinesInfo) {
99 Method.LineTable.push_back(
100 std::pair<unsigned, unsigned>{ Sym->getOffset(),
113 if (Batch.Methods.empty()) {
117 std::lock_guard<std::mutex> Lock(PluginMutex);
118 uint64_t Allocated = Batch.Methods.size();
119 uint64_t Start = NextMethodID;
120 NextMethodID += Allocated;
121 for (
size_t i = Start; i < NextMethodID; ++i) {
122 Batch.Methods[i - Start].MethodID = i;
124 this->PendingMethodIDs[MR] = {Start, Allocated};
126 G.allocActions().push_back(
129 RegisterVTuneImplAddr, Batch)),
137 std::lock_guard<std::mutex> Lock(PluginMutex);
138 auto I = PendingMethodIDs.find(MR);
139 if (I == PendingMethodIDs.end())
142 LoadedMethodIDs[K].push_back(I->second);
143 PendingMethodIDs.erase(I);
151 std::lock_guard<std::mutex> Lock(PluginMutex);
152 PendingMethodIDs.erase(&MR);
158 if (!UnregisterVTuneImpl) {
163 std::lock_guard<std::mutex> Lock(PluginMutex);
164 auto I = LoadedMethodIDs.find(
K);
165 if (
I == LoadedMethodIDs.end())
168 UnloadedIDs = std::move(
I->second);
169 LoadedMethodIDs.erase(
I);
171 if (
auto Err = UnregisterVTuneImpl(EPC.getExecutionSession(), UnloadedIDs))
180 std::lock_guard<std::mutex> Lock(PluginMutex);
181 auto I = LoadedMethodIDs.find(SrcKey);
182 if (
I == LoadedMethodIDs.end())
185 auto &Dest = LoadedMethodIDs[DstKey];
187 LoadedMethodIDs.erase(SrcKey);
192 bool EmitDebugInfo,
bool TestMode) {
193 auto &ES = EPC.getExecutionSession();
194 auto RegisterImplName =
200 return Res.takeError();
202 Res->find(RegisterImplName)->second.getAddress());
204 Res->find(UnregisterImplName)->second.getAddress());
205 return std::make_unique<VTuneSupportPlugin>(
206 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