From 7d1ec5d580ebef22e950b5cfbaf235648a0df285 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 6 Feb 2026 00:47:00 +0100 Subject: [PATCH 1/3] [SYCL][LIT] Check POD-ness for types crossing ABI boundary --- sycl/test/abi/abi_crossing_type_traits.cpp | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 sycl/test/abi/abi_crossing_type_traits.cpp diff --git a/sycl/test/abi/abi_crossing_type_traits.cpp b/sycl/test/abi/abi_crossing_type_traits.cpp new file mode 100644 index 0000000000000..bba58cfcbb103 --- /dev/null +++ b/sycl/test/abi/abi_crossing_type_traits.cpp @@ -0,0 +1,168 @@ +// Test to check type traits of SYCL types when crossing ABI boundaries. +// Type traits, like POD, trivially copyable, standard layout, etc if changed +// outside the ABI breaking window can break the ABI and cause UB. + +// RUN: %clangxx -fsycl -o %t.out %s +// RUN: %t.out 2>&1 | FileCheck %s + +#include +#include +#include +#include +#include + +using namespace sycl; + +// For a type to be POD, it has to be trivial and standard layout. +// For a type to be trivial, it has to be trivially copyable and +// trivially default constructible. +// Don't use std::is_pod as it is deprecated in C++20 or std::is_trivial +// as it will be deprecated in C++26. +template +void check_type_traits() { + std::cout << "Type: " << typeid(T).name() << "\n"; + std::cout << "Trivially copyable: " + << std::is_trivially_copyable_v << "\n"; + std::cout << "Trivially default constructible: " + << std::is_trivially_default_constructible_v << "\n"; + std::cout << "Standard layout: " << std::is_standard_layout_v << "\n"; +} + +int main() { + + // CHECK: Type: N4sycl3_V16deviceE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V16bufferIiLi1ENS0_6detail17aligned_allocatorIiEEvEE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V18accessorIiLi1ELNS0_6access4modeE1026ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_3ext6oneapi22accessor_property_listIJEEEEE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits< + accessor>(); + + // CHECK-NEXT: Type: N4sycl3_V114local_accessorIiLi1EEE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V12idILi3EEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V15rangeILi3EEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V14itemILi3ELb1EEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V17nd_itemILi3EEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V18nd_rangeILi3EEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V16detail27compile_time_kernel_info_v123CompileTimeKernelInfoTyE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits< + detail::compile_time_kernel_info_v1::CompileTimeKernelInfoTy>(); + + // CHECK-NEXT: Type: N4sycl3_V19exceptionE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V17handlerE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V16detail17HostKernelRefBaseE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V15imageILi1ENS0_6detail17aligned_allocatorIhEEEE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V16detail16nd_range_view_v113nd_range_viewE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V16detail27kernel_launch_properties_v111PropsHolderIJNS0_3ext6oneapi12experimental23work_group_scratch_sizeENS4_5intel12experimental12cache_configENS6_17use_root_sync_keyENS6_23work_group_progress_keyENS6_22sub_group_progress_keyENS6_22work_item_progress_keyENS6_4cuda12cluster_sizeILi1EEENSG_ILi2EEENSG_ILi3EEEEEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V14spanIiLm4EEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V16detail14tls_code_loc_tE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V13vecIiLi4EEE + // CHECK-NEXT: Trivially copyable: 1 + // CHECK-NEXT: Trivially default constructible: 1 + // CHECK-NEXT: Standard layout: 1 + check_type_traits>(); + + // CHECK-NEXT: Type: N4sycl3_V16detail20PropertyWithDataBaseE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V16detail19SYCLMemObjAllocatorE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + // CHECK-NEXT: Type: N4sycl3_V115device_selectorE + // CHECK-NEXT: Trivially copyable: 0 + // CHECK-NEXT: Trivially default constructible: 0 + // CHECK-NEXT: Standard layout: 0 + check_type_traits(); + + return 0; +} \ No newline at end of file From ec9058558d971d19467d3504f98752274a0784af Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 6 Feb 2026 00:50:12 +0100 Subject: [PATCH 2/3] clang format --- sycl/test/abi/abi_crossing_type_traits.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sycl/test/abi/abi_crossing_type_traits.cpp b/sycl/test/abi/abi_crossing_type_traits.cpp index bba58cfcbb103..e2227cc9cae84 100644 --- a/sycl/test/abi/abi_crossing_type_traits.cpp +++ b/sycl/test/abi/abi_crossing_type_traits.cpp @@ -18,8 +18,7 @@ using namespace sycl; // trivially default constructible. // Don't use std::is_pod as it is deprecated in C++20 or std::is_trivial // as it will be deprecated in C++26. -template -void check_type_traits() { +template void check_type_traits() { std::cout << "Type: " << typeid(T).name() << "\n"; std::cout << "Trivially copyable: " << std::is_trivially_copyable_v << "\n"; @@ -47,7 +46,7 @@ int main() { // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits< - accessor>(); + accessor>(); // CHECK-NEXT: Type: N4sycl3_V114local_accessorIiLi1EEE // CHECK-NEXT: Trivially copyable: 0 @@ -90,7 +89,7 @@ int main() { // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits< - detail::compile_time_kernel_info_v1::CompileTimeKernelInfoTy>(); + detail::compile_time_kernel_info_v1::CompileTimeKernelInfoTy>(); // CHECK-NEXT: Type: N4sycl3_V19exceptionE // CHECK-NEXT: Trivially copyable: 0 From 2b561f259ee826c1dbb6ef6fbca9922a169d3531 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 6 Feb 2026 18:19:02 +0100 Subject: [PATCH 3/3] Don't print type --- sycl/test/abi/abi_crossing_type_traits.cpp | 27 ++-------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/sycl/test/abi/abi_crossing_type_traits.cpp b/sycl/test/abi/abi_crossing_type_traits.cpp index e2227cc9cae84..9c0556b60c270 100644 --- a/sycl/test/abi/abi_crossing_type_traits.cpp +++ b/sycl/test/abi/abi_crossing_type_traits.cpp @@ -19,7 +19,6 @@ using namespace sycl; // Don't use std::is_pod as it is deprecated in C++20 or std::is_trivial // as it will be deprecated in C++26. template void check_type_traits() { - std::cout << "Type: " << typeid(T).name() << "\n"; std::cout << "Trivially copyable: " << std::is_trivially_copyable_v << "\n"; std::cout << "Trivially default constructible: " @@ -29,139 +28,117 @@ template void check_type_traits() { int main() { - // CHECK: Type: N4sycl3_V16deviceE - // CHECK-NEXT: Trivially copyable: 0 + // CHECK: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V16bufferIiLi1ENS0_6detail17aligned_allocatorIiEEvEE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V18accessorIiLi1ELNS0_6access4modeE1026ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_3ext6oneapi22accessor_property_listIJEEEEE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits< accessor>(); - // CHECK-NEXT: Type: N4sycl3_V114local_accessorIiLi1EEE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V12idILi3EEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V15rangeILi3EEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V14itemILi3ELb1EEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V17nd_itemILi3EEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V18nd_rangeILi3EEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V16detail27compile_time_kernel_info_v123CompileTimeKernelInfoTyE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits< detail::compile_time_kernel_info_v1::CompileTimeKernelInfoTy>(); - // CHECK-NEXT: Type: N4sycl3_V19exceptionE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V17handlerE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V16detail17HostKernelRefBaseE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V15imageILi1ENS0_6detail17aligned_allocatorIhEEEE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V16detail16nd_range_view_v113nd_range_viewE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V16detail27kernel_launch_properties_v111PropsHolderIJNS0_3ext6oneapi12experimental23work_group_scratch_sizeENS4_5intel12experimental12cache_configENS6_17use_root_sync_keyENS6_23work_group_progress_keyENS6_22sub_group_progress_keyENS6_22work_item_progress_keyENS6_4cuda12cluster_sizeILi1EEENSG_ILi2EEENSG_ILi3EEEEEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V14spanIiLm4EEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V16detail14tls_code_loc_tE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V13vecIiLi4EEE // CHECK-NEXT: Trivially copyable: 1 // CHECK-NEXT: Trivially default constructible: 1 // CHECK-NEXT: Standard layout: 1 check_type_traits>(); - // CHECK-NEXT: Type: N4sycl3_V16detail20PropertyWithDataBaseE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V16detail19SYCLMemObjAllocatorE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); - // CHECK-NEXT: Type: N4sycl3_V115device_selectorE // CHECK-NEXT: Trivially copyable: 0 // CHECK-NEXT: Trivially default constructible: 0 // CHECK-NEXT: Standard layout: 0 check_type_traits(); return 0; -} \ No newline at end of file +}