TL;DR This patch adds address sanitizer instrumentation support for accesses to global and constant address spaces in AMDGPU. It strictly avoids instrumenting the stack and assumes x86 as the host.
This patch adds address sanitizer instrumentations to global accesses (addrspace 1 and 4) for the device/GPU code. These addresses are accessible from both the host/CPU and the device/GPU therefore we use the static shadow mapping from the host. For addresses explicitly in addrspace 1 and 4, we can follow the exact same instrumentation that is done for the host.
There are generic/flat addresses (addrspace 0) that can point to global memory (addrspace 1 and 4). We add runtime calls (llvm.amdgcn.is.shared and llvm.amdgcn.is.private) to check if the flat address is a global address at runtime. If it is then we instrument it as we would do for explicit accesses to addrspace 1 or 4.
Is it fine that I've created variables for them or shall I directly use function names as string inside getOrInsertFunction?