From a1355e8717c4c10113b9f3b0e2e214e02c70c421 Mon Sep 17 00:00:00 2001 From: Udit Kumar Agarwal Date: Tue, 10 Dec 2024 09:41:55 -0800 Subject: [PATCH] [SYCL] Fix Coverity issues after #16228 (#16313) All of these Coverity issues are related to using `std::move()` instead of variable copy. --- sycl/source/detail/kernel_bundle_impl.hpp | 2 +- .../detail/program_manager/program_manager.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 9366398a6a05d..e538318f807b7 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -164,7 +164,7 @@ class kernel_bundle_impl { detail::ProgramManager::getInstance().build(DevImgWithDeps, MDevices, PropList); MDeviceImages.emplace_back(BuiltImg); - MUniqueDeviceImages.push_back(BuiltImg); + MUniqueDeviceImages.emplace_back(BuiltImg); break; } case bundle_state::input: diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 8852d050fc164..c7a3a2491f72c 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -822,7 +822,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( std::copy(DeviceImagesToLink.begin(), DeviceImagesToLink.end(), std::back_inserter(AllImages)); - return getBuiltURProgram(AllImages, Context, {Device}); + return getBuiltURProgram(std::move(AllImages), Context, {Device}); } ur_program_handle_t ProgramManager::getBuiltURProgram( @@ -2400,7 +2400,8 @@ ProgramManager::getSYCLDeviceImagesWithCompatibleState( std::vector Images; const std::set &Deps = ImgInfoPair.second.Deps; Images.reserve(Deps.size() + 1); - Images.push_back(createSyclObjFromImpl(MainImpl)); + Images.push_back( + createSyclObjFromImpl(std::move(MainImpl))); for (RTDeviceBinaryImage *Dep : Deps) { std::shared_ptr> DepKernelIDs; { @@ -2414,7 +2415,8 @@ ProgramManager::getSYCLDeviceImagesWithCompatibleState( Dep, Ctx, Devs, ImgInfoPair.second.State, DepKernelIDs, /*PIProgram=*/nullptr); - Images.push_back(createSyclObjFromImpl(DepImpl)); + Images.push_back( + createSyclObjFromImpl(std::move(DepImpl))); } SYCLDeviceImages.push_back(std::move(Images)); } @@ -2600,7 +2602,7 @@ ProgramManager::compile(const DevImgPlainWithDeps &ImgWithDeps, getSyclObjImpl(ObjectImpl->get_context()))); CompiledImages.push_back( - createSyclObjFromImpl(ObjectImpl)); + createSyclObjFromImpl(std::move(ObjectImpl))); } return CompiledImages; } @@ -2775,14 +2777,14 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps, SpecConstMap = MainInputImpl->get_spec_const_data_ref(); } - ur_program_handle_t ResProgram = - getBuiltURProgram(BinImgs, Context, Devs, &DevImgWithDeps, SpecConstBlob); + ur_program_handle_t ResProgram = getBuiltURProgram( + std::move(BinImgs), Context, Devs, &DevImgWithDeps, SpecConstBlob); DeviceImageImplPtr ExecImpl = std::make_shared( MainInputImpl->get_bin_image_ref(), Context, Devs, bundle_state::executable, std::move(KernelIDs), ResProgram, std::move(SpecConstMap), std::move(SpecConstBlob)); - return createSyclObjFromImpl(ExecImpl); + return createSyclObjFromImpl(std::move(ExecImpl)); } // When caching is enabled, the returned UrKernel will already have