[PATCH] D107971: [openmp] Annotate tmp variables with omp_thread_mem_alloc

Jon Chesterfield via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 12 09:03:40 PDT 2021


JonChesterfield created this revision.
JonChesterfield added reviewers: arsenm, jdoerfert.
Herald added subscribers: guansong, yaxunl.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

Fixes miscompile of calls into ocml. Bug 51445.

The stack variable `double __tmp` is moved to dynamically allocated shared
memory by CGOpenMPRuntimeGPU. This is usually fine, but when the variable
is passed to a function that is explicitly annotated address_space(5) then
allocating the variable off-stack leads to a miscompile in the back end,
which cannot decide to move the variable back to the stack from shared.

This could be fixed by removing the AS(5) annotation from the math library
or by explicitly marking the variables as thread_mem_alloc. The cast to
AS(5) is still a no-op once IR is reached.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107971

Files:
  clang/lib/Headers/__clang_hip_math.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107971.366012.patch
Type: text/x-patch
Size: 3522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210812/ffcac2d8/attachment.bin>


More information about the cfe-commits mailing list