@@ -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))
@@ -360,7 +365,7 @@ using MakeGlobalType = typename sycl::detail::DecoratedType<
360
365
T, sycl::access::address_space::global_space>::type;
361
366
362
367
#define DefStateSetWithType (name, field, type ) \
363
- DEVICE_EXTERNAL_C void __dpcpp_nativecpu_##name( \
368
+ DEVICE_EXTERNAL_C USED void __dpcpp_nativecpu_##name( \
364
369
type value, MakeGlobalType<__nativecpu_state> *s) { \
365
370
s->field = value; \
366
371
} \
@@ -372,7 +377,7 @@ DefStateSetWithType(set_sub_group_id, SubGroup_id, uint32_t);
372
377
DefStateSetWithType (set_max_sub_group_size, SubGroup_size, uint32_t );
373
378
374
379
#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( \
376
381
MakeGlobalType<const __nativecpu_state> *s) { \
377
382
return s->field ; \
378
383
} \
@@ -388,7 +393,7 @@ DefineStateGet_U32(get_max_sub_group_size, SubGroup_size);
388
393
DefineStateGet_U32 (get_num_sub_groups, NumSubGroups);
389
394
390
395
#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( \
392
397
ptype dim, MakeGlobalType<const __nativecpu_state> *s) { \
393
398
return s->field [dim]; \
394
399
} \
@@ -406,9 +411,9 @@ DefineStateGet_U64(get_num_groups, MNumGroups);
406
411
DefineStateGet_U64 (get_wg_size, MWorkGroup_size);
407
412
DefineStateGet_U64 (get_wg_id, MWorkGroup_id);
408
413
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) {
412
417
s->MLocal_id [dim] = value;
413
418
s->MGlobal_id [dim] = s->MWorkGroup_size [dim] * s->MWorkGroup_id [dim] +
414
419
s->MLocal_id [dim] + s->MGlobalOffset [dim];
0 commit comments