[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

Jon Chesterfield via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 3 08:02:32 PDT 2022


JonChesterfield added a comment.

In D130096#3816149 <https://reviews.llvm.org/D130096#3816149>, @arsenm wrote:

> I'd prefer to avoid spreading special treatment of the device libraries into the backend. The contract is poorly defined and spread around too much as it is





================
Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:2-3
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-globals --include-generated-funcs --global-value-regex "__oclc_daz_opt"
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -emit-llvm-bc -o %t.bc -DLIBRARY %s
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -mlink-builtin-bitcode %t.bc -S -emit-llvm -o - %s | FileCheck %s
+
----------------
jhuber6 wrote:
> jhuber6 wrote:
> > yaxunl wrote:
> > > This is compiling HIP as host. Please add -fcuda-is-device.
> > This test should only require that the triple is `amdgcn`. I could potentially make the generation of the constants require HIP or OpenMPDevice, or OpenCL is enabled if you think that's bad.
> I can also change it to just `-x c` if the HIP is the problem.
We probably want these magic constants for C++ code as well, so keying it off the triple (at least triple + that we're using rocm / compute stuff, which I think is adequately indicated by hsa in the triple) is better. And likewise don't want to emit these constants for non-gpu code, e.g. x64 host hip doesn't need the daz_opt constant, which also suggests triple is the right hook.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130096/new/

https://reviews.llvm.org/D130096



More information about the cfe-commits mailing list