Skip to content

Commit 4bc5719

Browse files
committed
Changed single statement style in if body and added LoadedMethodIDs.erase(SrcKey)
1 parent b12dc95 commit 4bc5719

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) {
3131
if (EmitDebugInfo) {
3232
auto EDC = createDWARFContext(G);
3333
if (!EDC) {
34-
// ERROR
3534
EmitDebugInfo = false;
3635
} else {
3736
DC = std::move(EDC->first);
@@ -42,16 +41,15 @@ static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) {
4241
auto GetStringIdx = [Deduplicator = StringMap<uint32_t>(),
4342
&Batch](StringRef S) mutable {
4443
auto I = Deduplicator.find(S);
45-
if (I != Deduplicator.end()) {
44+
if (I != Deduplicator.end())
4645
return I->second;
47-
}
46+
4847
Batch.Strings.push_back(S.str());
4948
return Deduplicator[S] = Batch.Strings.size();
5049
};
5150
for (auto Sym : G.defined_symbols()) {
52-
if (!Sym->isCallable()) {
51+
if (!Sym->isCallable())
5352
continue;
54-
}
5553

5654
Batch.Methods.push_back(VTuneMethodInfo());
5755
auto &Method = Batch.Methods.back();
@@ -63,10 +61,9 @@ static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) {
6361
Method.ClassFileSI = 0;
6462
Method.SourceFileSI = 0;
6563

66-
if (!EmitDebugInfo) {
64+
if (!EmitDebugInfo)
6765
continue;
68-
}
69-
// TODO: Emit debug info
66+
7067
auto &Section = Sym->getBlock().getSection();
7168
auto Addr = Sym->getAddress();
7269
auto SAddr =
@@ -94,7 +91,6 @@ void VTuneSupportPlugin::modifyPassConfig(MaterializationResponsibility &MR,
9491
// the object file is generated but not linked yet
9592
auto Batch = getMethodBatch(G, EmitDebugInfo);
9693
if (Batch.Methods.empty()) {
97-
// Nothing to do.
9894
return Error::success();
9995
}
10096
{
@@ -120,9 +116,9 @@ Error VTuneSupportPlugin::notifyEmitted(MaterializationResponsibility &MR) {
120116
if (auto Err = MR.withResourceKeyDo([this, MR = &MR](ResourceKey K) {
121117
std::lock_guard<std::mutex> Lock(PluginMutex);
122118
auto I = PendingMethodIDs.find(MR);
123-
if (I == PendingMethodIDs.end()) {
119+
if (I == PendingMethodIDs.end())
124120
return;
125-
}
121+
126122
LoadedMethodIDs[K].push_back(I->second);
127123
PendingMethodIDs.erase(I);
128124
})) {
@@ -146,16 +142,16 @@ Error VTuneSupportPlugin::notifyRemovingResources(JITDylib &JD, ResourceKey K) {
146142
{
147143
std::lock_guard<std::mutex> Lock(PluginMutex);
148144
auto I = LoadedMethodIDs.find(K);
149-
if (I == LoadedMethodIDs.end()) {
145+
if (I == LoadedMethodIDs.end())
150146
return Error::success();
151-
}
147+
152148
UnloadedIDs = std::move(I->second);
153149
LoadedMethodIDs.erase(I);
154150
}
155151
if (auto Err = EPC.callSPSWrapper<void(shared::SPSVTuneUnloadedMethodIDs)>(
156-
UnregisterVTuneImplAddr, UnloadedIDs)) {
152+
UnregisterVTuneImplAddr, UnloadedIDs))
157153
return Err;
158-
}
154+
159155
return Error::success();
160156
}
161157

@@ -164,11 +160,12 @@ void VTuneSupportPlugin::notifyTransferringResources(JITDylib &JD,
164160
ResourceKey SrcKey) {
165161
std::lock_guard<std::mutex> Lock(PluginMutex);
166162
auto I = LoadedMethodIDs.find(SrcKey);
167-
if (I == LoadedMethodIDs.end()) {
163+
if (I == LoadedMethodIDs.end())
168164
return;
169-
}
165+
170166
auto &Dest = LoadedMethodIDs[DstKey];
171167
Dest.insert(Dest.end(), I->second.begin(), I->second.end());
168+
LoadedMethodIDs.erase(SrcKey);
172169
}
173170

174171
Expected<std::unique_ptr<VTuneSupportPlugin>>

llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderVTune.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ static void registerJITLoaderVTuneUnregisterImpl(
8787
extern "C" llvm::orc::shared::CWrapperFunctionResult
8888
llvm_orc_registerVTuneImpl(const char *Data, uint64_t Size) {
8989
using namespace orc::shared;
90-
if (!Wrapper) {
90+
if (!Wrapper)
9191
Wrapper.reset(new IntelJITEventsWrapper);
92-
}
9392

9493
return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
9594
Data, Size, registerJITLoaderVTuneRegisterImpl)
@@ -170,7 +169,6 @@ static unsigned int GetNewMethodID(void) {
170169
extern "C" llvm::orc::shared::CWrapperFunctionResult
171170
llvm_orc_test_registerVTuneImpl(const char *Data, uint64_t Size) {
172171
using namespace orc::shared;
173-
// TODO: replace Wrapper with test mocking
174172
Wrapper.reset(new IntelJITEventsWrapper(
175173
NotifyEvent, NULL, NULL, IsProfilingActive, 0, 0, GetNewMethodID));
176174
return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(

0 commit comments

Comments
 (0)