Skip to content

Commit 764e2ba

Browse files
[SYCL][NFC] Properly use emplace_back in sycl-post-link (#7469)
We used to create a temporary object and pass it to `emplace_back`. Refactored code so we pass arguments to constructor directly without creating a temporary object.
1 parent 572bc50 commit 764e2ba

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

llvm/tools/sycl-post-link/ModuleSplitter.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ groupEntryPointsByKernelType(ModuleDesc &MD,
178178

179179
if (!EntryPointMap.empty()) {
180180
for (auto &EPG : EntryPointMap) {
181-
EntryPointGroups.emplace_back(EntryPointGroup{
182-
EPG.first, std::move(EPG.second), MD.getEntryPointGroup().Props});
181+
EntryPointGroups.emplace_back(EPG.first, std::move(EPG.second),
182+
MD.getEntryPointGroup().Props);
183183
EntryPointGroup &G = EntryPointGroups.back();
184184

185185
if (G.GroupId == ESIMD_SCOPE_NAME) {
@@ -191,8 +191,7 @@ groupEntryPointsByKernelType(ModuleDesc &MD,
191191
}
192192
} else {
193193
// No entry points met, record this.
194-
EntryPointGroups.emplace_back(
195-
EntryPointGroup{SYCL_SCOPE_NAME, EntryPointSet{}});
194+
EntryPointGroups.emplace_back(SYCL_SCOPE_NAME, EntryPointSet{});
196195
EntryPointGroup &G = EntryPointGroups.back();
197196
G.Props.HasESIMD = SyclEsimdSplitStatus::SYCL_ONLY;
198197
}
@@ -250,15 +249,14 @@ EntryPointGroupVec groupEntryPointsByScope(ModuleDesc &MD,
250249
if (!EntryPointMap.empty()) {
251250
EntryPointGroups.reserve(EntryPointMap.size());
252251
for (auto &EPG : EntryPointMap) {
253-
EntryPointGroups.emplace_back(EntryPointGroup{
254-
EPG.first, std::move(EPG.second), MD.getEntryPointGroup().Props});
252+
EntryPointGroups.emplace_back(EPG.first, std::move(EPG.second),
253+
MD.getEntryPointGroup().Props);
255254
EntryPointGroup &G = EntryPointGroups.back();
256255
G.Props.Scope = EntryScope;
257256
}
258257
} else {
259258
// No entry points met, record this.
260-
EntryPointGroups.emplace_back(
261-
EntryPointGroup{GLOBAL_SCOPE_NAME, EntryPointSet{}});
259+
EntryPointGroups.emplace_back(GLOBAL_SCOPE_NAME, EntryPointSet{});
262260
}
263261
return EntryPointGroups;
264262
}
@@ -287,13 +285,13 @@ groupEntryPointsByAttribute(ModuleDesc &MD, StringRef AttrName,
287285
if (!EntryPointMap.empty()) {
288286
EntryPointGroups.reserve(EntryPointMap.size());
289287
for (auto &EPG : EntryPointMap) {
290-
EntryPointGroups.emplace_back(EntryPointGroup{
291-
EPG.first, std::move(EPG.second), MD.getEntryPointGroup().Props});
288+
EntryPointGroups.emplace_back(EPG.first, std::move(EPG.second),
289+
MD.getEntryPointGroup().Props);
292290
F(EntryPointGroups.back());
293291
}
294292
} else {
295293
// No entry points met, record this.
296-
EntryPointGroups.push_back({GLOBAL_SCOPE_NAME, {}});
294+
EntryPointGroups.emplace_back(GLOBAL_SCOPE_NAME, EntryPointSet{});
297295
F(EntryPointGroups.back());
298296
}
299297
return EntryPointGroups;

0 commit comments

Comments
 (0)