@@ -29,6 +29,11 @@ using __nativecpu_state = native_cpu::state;
29
29
#define DEVICE_EXTERNAL_C DEVICE_EXTERN_C __attribute__ ((always_inline))
30
30
#define DEVICE_EXTERNAL SYCL_EXTERNAL __attribute__ ((always_inline))
31
31
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
+
32
37
#define OCL_LOCAL __attribute__ ((opencl_local))
33
38
#define OCL_GLOBAL __attribute__ ((opencl_global))
34
39
#define OCL_PRIVATE __attribute__ ((opencl_private))
@@ -354,7 +359,7 @@ using MakeGlobalType = typename sycl::detail::DecoratedType<
354
359
T, sycl::access::address_space::global_space>::type;
355
360
356
361
#define DefStateSetWithType (name, field, type ) \
357
- DEVICE_EXTERNAL_C void __dpcpp_nativecpu_##name( \
362
+ DEVICE_EXTERNAL_C USED void __dpcpp_nativecpu_##name( \
358
363
type value, MakeGlobalType<__nativecpu_state> *s) { \
359
364
s->field = value; \
360
365
} \
@@ -366,7 +371,7 @@ DefStateSetWithType(set_sub_group_id, SubGroup_id, uint32_t);
366
371
DefStateSetWithType (set_max_sub_group_size, SubGroup_size, uint32_t );
367
372
368
373
#define DefineStateGetWithType (name, field, type ) \
369
- DEVICE_EXTERNAL_C GET_PROPS type __dpcpp_nativecpu_##name( \
374
+ DEVICE_EXTERNAL_C GET_PROPS USED type __dpcpp_nativecpu_##name( \
370
375
MakeGlobalType<const __nativecpu_state> *s) { \
371
376
return s->field ; \
372
377
} \
@@ -382,7 +387,7 @@ DefineStateGet_U32(get_max_sub_group_size, SubGroup_size);
382
387
DefineStateGet_U32 (get_num_sub_groups, NumSubGroups);
383
388
384
389
#define DefineStateGetWithType2 (name, field, rtype, ptype ) \
385
- DEVICE_EXTERNAL_C GET_PROPS rtype __dpcpp_nativecpu_##name( \
390
+ DEVICE_EXTERNAL_C GET_PROPS USED rtype __dpcpp_nativecpu_##name( \
386
391
ptype dim, MakeGlobalType<const __nativecpu_state> *s) { \
387
392
return s->field [dim]; \
388
393
} \
@@ -400,9 +405,9 @@ DefineStateGet_U64(get_num_groups, MNumGroups);
400
405
DefineStateGet_U64 (get_wg_size, MWorkGroup_size);
401
406
DefineStateGet_U64 (get_wg_id, MWorkGroup_id);
402
407
403
- DEVICE_EXTERNAL_C
404
- void __dpcpp_nativecpu_set_local_id (uint32_t dim, uint64_t value,
405
- MakeGlobalType<__nativecpu_state> *s) {
408
+ DEVICE_EXTERNAL_C USED void
409
+ __dpcpp_nativecpu_set_local_id (uint32_t dim, uint64_t value,
410
+ MakeGlobalType<__nativecpu_state> *s) {
406
411
s->MLocal_id [dim] = value;
407
412
s->MGlobal_id [dim] = s->MWorkGroup_size [dim] * s->MWorkGroup_id [dim] +
408
413
s->MLocal_id [dim] + s->MGlobalOffset [dim];
0 commit comments