Skip to content

[SYCL][LIT] Check POD-ness for types crossing ABI boundary#21229

Open
uditagarwal97 wants to merge 3 commits intosyclfrom
private/udit/abi_pod_test
Open

[SYCL][LIT] Check POD-ness for types crossing ABI boundary#21229
uditagarwal97 wants to merge 3 commits intosyclfrom
private/udit/abi_pod_test

Conversation

@uditagarwal97
Copy link
Contributor

Added test to check POD-ness of SYCL types when crossing ABI boundaries. POD-ness if changed outside the ABI breaking window, can break the ABI and cause undefined behavior.

std::cout << "Standard layout: " << std::is_standard_layout_v<T> << "\n";
}

int main() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not exhaustive and I only considered types for which we already have abi layout tests.

@uditagarwal97 uditagarwal97 requested a review from Copilot February 5, 2026 23:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a LIT test to verify type traits (POD-ness, trivial copyability, standard layout) of SYCL types that cross ABI boundaries, ensuring these properties remain stable to prevent ABI breakage and undefined behavior.

Changes:

  • Added comprehensive type trait verification test for 18 SYCL types commonly used across ABI boundaries
  • Implemented test infrastructure using FileCheck to validate type properties remain consistent

@uditagarwal97
Copy link
Contributor Author

I think I'd have to split this test for Linux and Windows... Some types are standard_layout for gcc but not for MSVC.

Comment on lines +22 to +27
std::cout << "Trivially copyable: "
<< std::is_trivially_copyable_v<T> << "\n";
std::cout << "Trivially default constructible: "
<< std::is_trivially_default_constructible_v<T> << "\n";
std::cout << "Standard layout: " << std::is_standard_layout_v<T> << "\n";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change cout/FileCheck to static_assert checks, i.e. something like:

template <typename T, bool IsTriviallyCopyable,
            bool IsTriviallyDefaultConstructible,
            bool IsStandardLayout>
  void check_type_traits() {
    static_assert(std::is_trivially_copyable_v<T> == IsTriviallyCopyable,
                  "Trivially copyable trait changed");
...

It will also allow to easier differentiate between msvc/gcc if any differences:

  #ifdef ..
    check_type_traits<some_type, false, false, false>();  // MSVC
  #else
    check_type_traits<some_type, false, false, true>();   // GCC
  #endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants