Skip to content

Commit 9758b95

Browse files
committed
Add a section about shadowed variables and host compiler approach
1 parent 6c7a9be commit 9758b95

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

sycl/doc/design/MappingHostAddressesToDeviceEntities.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,26 @@ Generated constructor contains a call to
319319
`__register_uniquely_identifiable_object` for each global variable which has
320320
`sycl-unique-id` and `sycl-uid-kind` attributes, passing values of those
321321
attributes into the corresponding arguments of the function.
322+
323+
### Handling shadowed variables
324+
325+
Unlike with the integration footer the problem with shadowed variables doesn't
326+
really exists with the custom host compiler approach, because it is compiler
327+
responsibility to uniquely identify shadowed variables at LLVM IR level and we
328+
are simply re-using what is already there.
329+
330+
For example, for the following code snippet:
331+
332+
```
333+
sycl::device_global<int> FuBar;
334+
namespace {
335+
sycl::device_global<int> FuBar;
336+
}
337+
```
338+
339+
The following IR is generated by our host compiler:
340+
341+
```
342+
@FuBar = dso_local global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8
343+
@_ZN12_GLOBAL__N_15FuBarE = internal global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8
344+
```

0 commit comments

Comments
 (0)