@@ -29,6 +29,11 @@ using __nativecpu_state = native_cpu::state;
2929#define DEVICE_EXTERNAL_C DEVICE_EXTERN_C __attribute__ ((always_inline))
3030#define DEVICE_EXTERNAL SYCL_EXTERNAL __attribute__ ((always_inline))
3131
32+ // Several functions are used implicitly by WorkItemLoopsPass and
33+ // PrepareSYCLNativeCPUPass and need to be marked as used to prevent them being
34+ // removed early.
35+ #define USED __attribute__ ((used))
36+
3237#define OCL_LOCAL __attribute__ ((opencl_local))
3338#define OCL_GLOBAL __attribute__ ((opencl_global))
3439#define OCL_PRIVATE __attribute__ ((opencl_private))
@@ -360,7 +365,7 @@ using MakeGlobalType = typename sycl::detail::DecoratedType<
360365 T, sycl::access::address_space::global_space>::type;
361366
362367#define DefStateSetWithType (name, field, type ) \
363- DEVICE_EXTERNAL_C void __dpcpp_nativecpu_##name( \
368+ DEVICE_EXTERNAL_C USED void __dpcpp_nativecpu_##name( \
364369 type value, MakeGlobalType<__nativecpu_state> *s) { \
365370 s->field = value; \
366371 } \
@@ -372,7 +377,7 @@ DefStateSetWithType(set_sub_group_id, SubGroup_id, uint32_t);
372377DefStateSetWithType (set_max_sub_group_size, SubGroup_size, uint32_t );
373378
374379#define DefineStateGetWithType (name, field, type ) \
375- DEVICE_EXTERNAL_C GET_PROPS type __dpcpp_nativecpu_##name( \
380+ DEVICE_EXTERNAL_C GET_PROPS USED type __dpcpp_nativecpu_##name( \
376381 MakeGlobalType<const __nativecpu_state> *s) { \
377382 return s->field ; \
378383 } \
@@ -388,7 +393,7 @@ DefineStateGet_U32(get_max_sub_group_size, SubGroup_size);
388393DefineStateGet_U32 (get_num_sub_groups, NumSubGroups);
389394
390395#define DefineStateGetWithType2 (name, field, rtype, ptype ) \
391- DEVICE_EXTERNAL_C GET_PROPS rtype __dpcpp_nativecpu_##name( \
396+ DEVICE_EXTERNAL_C GET_PROPS USED rtype __dpcpp_nativecpu_##name( \
392397 ptype dim, MakeGlobalType<const __nativecpu_state> *s) { \
393398 return s->field [dim]; \
394399 } \
@@ -406,9 +411,9 @@ DefineStateGet_U64(get_num_groups, MNumGroups);
406411DefineStateGet_U64 (get_wg_size, MWorkGroup_size);
407412DefineStateGet_U64 (get_wg_id, MWorkGroup_id);
408413
409- DEVICE_EXTERNAL_C
410- void __dpcpp_nativecpu_set_local_id (uint32_t dim, uint64_t value,
411- MakeGlobalType<__nativecpu_state> *s) {
414+ DEVICE_EXTERNAL_C USED void
415+ __dpcpp_nativecpu_set_local_id (uint32_t dim, uint64_t value,
416+ MakeGlobalType<__nativecpu_state> *s) {
412417 s->MLocal_id [dim] = value;
413418 s->MGlobal_id [dim] = s->MWorkGroup_size [dim] * s->MWorkGroup_id [dim] +
414419 s->MLocal_id [dim] + s->MGlobalOffset [dim];
0 commit comments