diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index b710457da9c56..c39192f224760 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -79,7 +79,7 @@ buffer_impl::getNativeVector(backend BackendName) const { // doesn't have context and platform if (!Ctx) continue; - PlatformImplPtr Platform = Ctx->getPlatformImpl(); + const PlatformImplPtr &Platform = Ctx->getPlatformImpl(); assert(Platform && "Platform must be present for device context"); if (Platform->getBackend() != BackendName) continue; diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 80ae2ce4b0060..872790f07b886 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -90,7 +90,7 @@ class context_impl { const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } /// \return the PlatformImpl associated with this context. - PlatformImplPtr getPlatformImpl() const { return MPlatform; } + const PlatformImplPtr &getPlatformImpl() const { return MPlatform; } /// Queries this context for information. /// diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 2f45a0b288469..57c3f02fbd2b7 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -290,7 +290,7 @@ class device_impl { /// @brief Get the platform impl serving this device /// @return PlatformImplPtr - PlatformImplPtr getPlatformImpl() const { return MPlatform; } + const PlatformImplPtr &getPlatformImpl() const { return MPlatform; } /// Get device info string std::string get_device_info_string(ur_device_info_t InfoCode) const; diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 08e08000e9ae2..1a6ba43281f1d 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -600,7 +600,8 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { // The device is not necessarily a member of the context, it could be a // member's descendant instead. Fetch the corresponding device from the cache. - std::shared_ptr PltImpl = CtxImpl->getPlatformImpl(); + const std::shared_ptr &PltImpl = + CtxImpl->getPlatformImpl(); std::shared_ptr DevImpl = PltImpl->getDeviceImpl(DeviceId); if (DevImpl)