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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 16 15:34:31 PDT 2022


yaxunl added inline comments.


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:9468
+  // Control constants for math operations.
+  AddGlobal("__oclc_wavefrontsize64", Wavefront64, /*Size=*/8);
+  AddGlobal("__oclc_daz_opt", DenormAreZero, /*Size=*/8);
----------------
jhuber6 wrote:
> yaxunl wrote:
> > jhuber6 wrote:
> > > arsenm wrote:
> > > > yaxunl wrote:
> > > > > we need to disable emitting these variables for HIP -fgpu-rdc mode and OpenCL since they will break per-TU control variable. Other cases are OK.
> > > > wavefrontsize belongs with the system ones
> > > But the code would still depend on these and they wouldn't be present right
> > > wavefrontsize belongs with the system ones
> > 
> > You are right. `__oclc_wavefrontsize64` should always be emitted with linkonce_odr linkage since they need to be consistent among TU's. Therefore they should always be emitted.
> > 
> > `__oclc_daz_opt`, `__oclc_finite_only_opt`, `__oclc_unsafe_math_opt`, and `__oclc_correctly_rounded_sqrt32` can be different per TU, therefore they should not be emitted for HIP `-fgpu-rdc` and OpenCL.
> I'm still unsure, if we do not emit any of those control variables how will we use the device libraries for those builds.
> I'm still unsure, if we do not emit any of those control variables how will we use the device libraries for those builds.

In those cases, we will use -mlink-builtin-bitcode to get those variables from device libs, as we did before. They will have internal linkage after linking, therefore are per-TU.


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