From d8fadd28b6b2bcbe349b92fdd88224ebd8c048fe Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Tue, 12 Aug 2025 19:15:20 +0200 Subject: [PATCH 1/3] [SYCL] Add copy/move ctors and assignment operators to sycl::detail::optional Currently, those are implicitly defined and perform bitwise copy of Storage, that is incorrect if T has non-trivial copy ctors etc. --- sycl/include/sycl/detail/optional.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sycl/include/sycl/detail/optional.hpp b/sycl/include/sycl/detail/optional.hpp index ff14fabe82007..cfe4723367ce9 100644 --- a/sycl/include/sycl/detail/optional.hpp +++ b/sycl/include/sycl/detail/optional.hpp @@ -22,6 +22,15 @@ template class optional { public: constexpr optional() noexcept {} constexpr optional(std::nullopt_t) noexcept : optional() {} + constexpr optional(const optional &Other) + : ContainsValue{Other.ContainsValue} { + if (Other.ContainsValue) + new (Storage) T(Other.value()); + } + constexpr optional(optional &&Other) : ContainsValue{Other.ContainsValue} { + new (Storage) T(std::move(Other.value())); + Other.ContainsValue = false; + } template constexpr optional(const optional &Other) @@ -60,6 +69,21 @@ template class optional { return *this; } + optional &operator=(const optional &Other) { + if (has_value()) + reinterpret_cast(Storage)->~T(); + ContainsValue = Other.has_value(); + new (Storage) T(Other.value()); + return *this; + } + optional &operator=(optional &&Other) noexcept { + if (has_value()) + reinterpret_cast(Storage)->~T(); + ContainsValue = Other.has_value(); + new (Storage) T(std::move(Other.value())); + return *this; + } + template optional &operator=(const optional &Other) { if (has_value()) reinterpret_cast(Storage)->~T(); From 30b21eb1dc1fbe6dde29995ce9939417c8b191b7 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Thu, 14 Aug 2025 14:15:10 +0200 Subject: [PATCH 2/3] Cover fixed backward compatibility issues. --- devops/compat_ci_exclude.sycl-rel-6_2 | 9 --------- 1 file changed, 9 deletions(-) diff --git a/devops/compat_ci_exclude.sycl-rel-6_2 b/devops/compat_ci_exclude.sycl-rel-6_2 index d34b3ab81ab12..e19e571e70097 100644 --- a/devops/compat_ci_exclude.sycl-rel-6_2 +++ b/devops/compat_ci_exclude.sycl-rel-6_2 @@ -39,15 +39,6 @@ AsyncAlloc/device/ooo_queue_async_alloc_from_pool.cpp # Need more investigation by the author: -# https://github.com/intel/llvm/pull/18314 -Assert/assert_in_kernels.cpp -Assert/assert_in_multiple_tus.cpp -Assert/assert_in_multiple_tus_one_ndebug.cpp -Assert/assert_in_one_kernel.cpp -Assert/assert_in_simultaneous_kernels.cpp -Assert/assert_in_simultaneously_multiple_tus.cpp -Assert/assert_in_simultaneously_multiple_tus_one_ndebug.cpp - # https://github.com/intel/llvm/pull/17442 KernelCompiler/opencl.cpp KernelCompiler/opencl_cache_eviction.cpp From 797e879c374ca39e5b1ce7f61a9856cae8358922 Mon Sep 17 00:00:00 2001 From: Alexandr Konovalov Date: Thu, 14 Aug 2025 14:34:45 +0200 Subject: [PATCH 3/3] Fix after merge. --- devops/compat_ci_exclude.sycl-rel-6_2 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/devops/compat_ci_exclude.sycl-rel-6_2 b/devops/compat_ci_exclude.sycl-rel-6_2 index 2795b9969ae9b..70c340b0bf2a2 100644 --- a/devops/compat_ci_exclude.sycl-rel-6_2 +++ b/devops/compat_ci_exclude.sycl-rel-6_2 @@ -49,11 +49,6 @@ AsyncAlloc/device/ooo_queue_async_alloc_from_pool.cpp # Need more investigation by the author: -# https://github.com/intel/llvm/pull/17442 -KernelCompiler/opencl.cpp -KernelCompiler/opencl_cache_eviction.cpp -KernelCompiler/opencl_queries.cpp - # https://github.com/intel/llvm/pull/18403 (pulldown, so probably offload-tools # team should be looking into this) DeviceImageDependencies/NewOffloadDriver/dynamic.cpp