Skip to content

Commit

Permalink
[SYCLLowerIR] Fix warnings when std::moving temporaries (#14281)
Browse files Browse the repository at this point in the history
Moving a temporary variable prevents copy ellision, and by default
produces a compiler warning.

This PR also fixes up the naming of a few nearby variables to better
conform with LLVM (and the surrounding code).
  • Loading branch information
frasercrmck authored Jul 4, 2024
1 parent ee3d746 commit c844334
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/SYCLLowerIR/ModuleSplitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class ModuleSplitterBase {
Module &getInputModule() { return Input.getModule(); }

std::unique_ptr<Module> releaseInputModule() {
return std::move(Input.releaseModulePtr());
return Input.releaseModulePtr();
}

public:
Expand Down Expand Up @@ -274,9 +274,9 @@ getDeviceCodeSplitter(ModuleDesc &&MD, IRSplitMode Mode, bool IROutputOnly,
bool EmitOnlyKernelsAsEntryPoints);

#ifndef NDEBUG
void dumpEntryPoints(const EntryPointSet &C, const char *msg = "", int Tab = 0);
void dumpEntryPoints(const EntryPointSet &C, const char *Msg = "", int Tab = 0);
void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints = false,
const char *msg = "", int Tab = 0);
const char *Msg = "", int Tab = 0);
#endif // NDEBUG

struct SplitModule {
Expand Down
9 changes: 3 additions & 6 deletions llvm/include/llvm/SYCLLowerIR/Support.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
} while (false)

#define CHECK_AND_EXIT(E) \
{ \
Error LocE = std::move(E); \
if (LocE) { \
logAllUnhandledErrors(std::move(LocE), WithColor::error(errs())); \
exit(1); \
} \
if (Error LocE = E) { \
logAllUnhandledErrors(std::move(LocE), WithColor::error(errs())); \
exit(1); \
}

namespace llvm {
Expand Down
11 changes: 5 additions & 6 deletions llvm/lib/SYCLLowerIR/ModuleSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,8 @@ SmallVector<ModuleDesc, 2> splitByESIMD(ModuleDesc &&MD,
}

if (EntryPointGroups.size() == 1) {
Result.emplace_back(std::move(MD.releaseModulePtr()),
std::move(EntryPointGroups[0]), MD.Props);
Result.emplace_back(MD.releaseModulePtr(), std::move(EntryPointGroups[0]),
MD.Props);
return Result;
}

Expand All @@ -1164,18 +1164,17 @@ SmallVector<ModuleDesc, 2> splitByESIMD(ModuleDesc &&MD,
if (Group.isEsimd()) {
// For ESIMD module, we use full call graph of all entry points and all
// ESIMD functions.
Result.emplace_back(
std::move(extractESIMDSubModule(MD, std::move(Group), CG)));
Result.emplace_back(extractESIMDSubModule(MD, std::move(Group), CG));
} else {
// For non-ESIMD module we only use non-ESIMD functions. Additional filter
// is needed, because there could be uses of ESIMD functions from
// non-ESIMD functions through invoke_simd. If that is the case, both
// modules are expected to be linked back together after ESIMD functions
// were processed and therefore it is fine to return an "incomplete"
// module here.
Result.emplace_back(std::move(extractCallGraph(
Result.emplace_back(extractCallGraph(
MD, std::move(Group), CG,
[=](const Function *F) -> bool { return !isESIMDFunction(*F); })));
[=](const Function *F) -> bool { return !isESIMDFunction(*F); }));
}
}

Expand Down
8 changes: 4 additions & 4 deletions llvm/tools/sycl-post-link/sycl-post-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ module_split::ModuleDesc link(module_split::ModuleDesc &&MD1,
std::vector<std::string> Names;
MD1.saveEntryPointNames(Names);
MD2.saveEntryPointNames(Names);
bool link_error = llvm::Linker::linkModules(
MD1.getModule(), std::move(MD2.releaseModulePtr()));
bool LinkError =
llvm::Linker::linkModules(MD1.getModule(), MD2.releaseModulePtr());

if (link_error) {
if (LinkError) {
error(" error when linking SYCL and ESIMD modules");
}
module_split::ModuleDesc Res(MD1.releaseModulePtr(), std::move(Names));
Expand Down Expand Up @@ -491,7 +491,7 @@ processSpecConstantsWithDefaultValues(const module_split::ModuleDesc &MD) {
"This property should be true since the presence of SpecConsts "
"has been checked before the run of the pass");
NewModuleDesc->rebuildEntryPoints();
return std::move(NewModuleDesc);
return NewModuleDesc;
}

constexpr int MAX_COLUMNS_IN_FILE_TABLE = 3;
Expand Down

0 comments on commit c844334

Please sign in to comment.