[HIP][Clang][CodeGen] Add CodeGen support for `hipstdpar`
commitdd5d65adb6413122a5ba1ed04c5c2c0b4951b76c
authorAlex Voicu <alexandru.voicu@amd.com>
Tue, 17 Oct 2023 10:41:36 +0000 (17 11:41 +0100)
committerAlex Voicu <alexandru.voicu@amd.com>
Tue, 17 Oct 2023 10:41:36 +0000 (17 11:41 +0100)
treefe99fd9b87656416173d66b876f006ed0f7c7a53
parentbe9bc542186f92be2e644d2a3d506a3c9325ca3c
[HIP][Clang][CodeGen] Add CodeGen support for `hipstdpar`

This patch adds the CodeGen changes needed for enabling HIP parallel algorithm offload on AMDGPU targets. This change relaxes restrictions on what gets emitted on the device path, when compiling in `hipstdpar` mode:

1. Unless a function is explicitly marked `__host__`, it will get emitted, whereas before only `__device__` and `__global__` functions would be emitted;
2. Unsupported builtins are ignored as opposed to being marked as an error, as the decision on their validity is deferred to the `hipstdpar` specific code selection pass;
3. We add a `hipstdpar` specific pass to the opt pipeline, independent of optimisation level:
    - When compiling for the host, iff the user requested it via the `--hipstdpar-interpose-alloc` flag, we add a pass which replaces canonical allocation / deallocation functions with accelerator aware equivalents.

A test to validate that unannotated functions get correctly emitted is added as well.

Reviewed by: yaxunl, efriedma

Differential Revision: https://reviews.llvm.org/D155850
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CMakeLists.txt
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenHipStdPar/unannotated-functions-get-emitted.cpp [new file with mode: 0644]
clang/test/CodeGenHipStdPar/unsupported-ASM.cpp [new file with mode: 0644]
clang/test/CodeGenHipStdPar/unsupported-builtins.cpp [new file with mode: 0644]