From c8443343ef2f6f1e7e11c12fe16eaf9e94b4c7e9 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 4 Jul 2024 11:52:56 +0100 Subject: [PATCH] [SYCLLowerIR] Fix warnings when std::moving temporaries (#14281) 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). --- llvm/include/llvm/SYCLLowerIR/ModuleSplitter.h | 6 +++--- llvm/include/llvm/SYCLLowerIR/Support.h | 9 +++------ llvm/lib/SYCLLowerIR/ModuleSplitter.cpp | 11 +++++------ llvm/tools/sycl-post-link/sycl-post-link.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/llvm/include/llvm/SYCLLowerIR/ModuleSplitter.h b/llvm/include/llvm/SYCLLowerIR/ModuleSplitter.h index 2465bd212b6e0..f4214bb82cecf 100644 --- a/llvm/include/llvm/SYCLLowerIR/ModuleSplitter.h +++ b/llvm/include/llvm/SYCLLowerIR/ModuleSplitter.h @@ -237,7 +237,7 @@ class ModuleSplitterBase { Module &getInputModule() { return Input.getModule(); } std::unique_ptr releaseInputModule() { - return std::move(Input.releaseModulePtr()); + return Input.releaseModulePtr(); } public: @@ -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 { diff --git a/llvm/include/llvm/SYCLLowerIR/Support.h b/llvm/include/llvm/SYCLLowerIR/Support.h index ef537bbcd8b8d..e41aac7e24c85 100644 --- a/llvm/include/llvm/SYCLLowerIR/Support.h +++ b/llvm/include/llvm/SYCLLowerIR/Support.h @@ -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 { diff --git a/llvm/lib/SYCLLowerIR/ModuleSplitter.cpp b/llvm/lib/SYCLLowerIR/ModuleSplitter.cpp index 68104e85e4362..d9a11cd4a85b4 100644 --- a/llvm/lib/SYCLLowerIR/ModuleSplitter.cpp +++ b/llvm/lib/SYCLLowerIR/ModuleSplitter.cpp @@ -1154,8 +1154,8 @@ SmallVector 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; } @@ -1164,8 +1164,7 @@ SmallVector 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 @@ -1173,9 +1172,9 @@ SmallVector splitByESIMD(ModuleDesc &&MD, // 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); })); } } diff --git a/llvm/tools/sycl-post-link/sycl-post-link.cpp b/llvm/tools/sycl-post-link/sycl-post-link.cpp index 252f070652c4c..6760b2b1c6f7e 100644 --- a/llvm/tools/sycl-post-link/sycl-post-link.cpp +++ b/llvm/tools/sycl-post-link/sycl-post-link.cpp @@ -432,10 +432,10 @@ module_split::ModuleDesc link(module_split::ModuleDesc &&MD1, std::vector 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)); @@ -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;