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 = Deduplicator.find(S);
43 if (
I != Deduplicator.end())
46 Batch.
Strings.push_back(S.str());
47 return Deduplicator[S] = Batch.
Strings.size();
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();
74 Batch.
Strings.push_back(DC->getLineInfoForAddress(SAddr).FileName);
75 for (
auto &LInfo : LinesInfo) {
76 Method.LineTable.push_back(
90 if (Batch.Methods.empty()) {
94 std::lock_guard<std::mutex> Lock(PluginMutex);
95 uint64_t Allocated = Batch.Methods.size();
97 NextMethodID += Allocated;
98 for (
size_t i = Start; i < NextMethodID; ++i) {
99 Batch.Methods[i - Start].MethodID = i;
101 this->PendingMethodIDs[MR] = {Start, Allocated};
103 G.allocActions().push_back(
106 RegisterVTuneImplAddr, Batch)),
114 std::lock_guard<std::mutex> Lock(PluginMutex);
115 auto I = PendingMethodIDs.find(MR);
116 if (I == PendingMethodIDs.end())
119 LoadedMethodIDs[K].push_back(I->second);
120 PendingMethodIDs.erase(I);
128 std::lock_guard<std::mutex> Lock(PluginMutex);
129 PendingMethodIDs.erase(&MR);
135 if (!UnregisterVTuneImplAddr) {
140 std::lock_guard<std::mutex> Lock(PluginMutex);
141 auto I = LoadedMethodIDs.find(K);
142 if (
I == LoadedMethodIDs.end())
145 UnloadedIDs = std::move(
I->second);
146 LoadedMethodIDs.erase(
I);
149 UnregisterVTuneImplAddr, UnloadedIDs))
158 std::lock_guard<std::mutex> Lock(PluginMutex);
159 auto I = LoadedMethodIDs.find(SrcKey);
160 if (
I == LoadedMethodIDs.end())
163 auto &Dest = LoadedMethodIDs[DstKey];
164 Dest.insert(Dest.end(),
I->second.begin(),
I->second.end());
165 LoadedMethodIDs.erase(SrcKey);
170 bool EmitDebugInfo,
bool TestMode) {
172 auto RegisterImplName =
178 return Res.takeError();
180 Res->find(RegisterImplName)->second.getAddress());
182 Res->find(UnregisterImplName)->second.getAddress());
183 return std::make_unique<VTuneSupportPlugin>(
184 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.
Section & getSection() const
Return the parent section for this block.
Represents an object file section.
SectionOrdinal getOrdinal() const
Returns the ordinal for this section.
bool isCallable() const
Returns true is this symbol is callable.
StringRef getName() const
Returns the name of this symbol (empty if the symbol is anonymous).
orc::ExecutorAddr getAddress() const
Returns the address of this symbol.
Block & getBlock()
Return the Block 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...
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 cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...