Skip to content

Commit 9258938

Browse files
authored
[SYCL] Add standalone_debug attribute to sycl::device class (#19059)
A debug info optimization, known as "constructor homing," is enabled by default and omits debug information for certain constructors based on their characteristics. For the sycl::device class, the constructor is neither a copy/move constructor nor deleted, and is non-trivial, resulting in the omission of its debug information. This omission causes the pretty printer to fail, as it requires the debug information to display essential details such as types and device names. To resolve this, the pull request introduces the standalone_debug attribute to the sycl::device class, ensuring that debug information is always emitted for this class. While this change successfully addresses the pretty printer issue, it may lead to debug information being present in every compilation unit, potentially affecting code size. Testing with existing SYCL tests shows that the code size impact is relatively small, with increases ranging from approximately 0.6% to 1.5% in most cases.
1 parent 0e98f26 commit 9258938

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

sycl/include/sycl/detail/defines.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@
4444
#else
4545
#define __SYCL_BUILTIN_ALIAS(x)
4646
#endif
47+
48+
#if __has_cpp_attribute(_Clang::__standalone_debug__)
49+
#define __SYCL_STANDALONE_DEBUG [[_Clang::__standalone_debug__]]
50+
#else
51+
#define __SYCL_STANDALONE_DEBUG
52+
#endif

sycl/include/sycl/device.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ enum class peer_access {
6363
/// may be executed.
6464
///
6565
/// \ingroup sycl_api
66-
class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
66+
class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device
67+
: public detail::OwnerLessBase<device> {
6768
public:
6869
/// Constructs a SYCL device instance using the default device.
6970
device();

0 commit comments

Comments
 (0)