[all-commits] [llvm/llvm-project] b61135: [openmp] Annotate tmp variables with omp_thread_me...

Jon Chesterfield via All-commits all-commits at lists.llvm.org
Thu Aug 12 09:30:50 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b6113548c9217fb8a6d0e9ac5bef5584c1aa614d
      https://github.com/llvm/llvm-project/commit/b6113548c9217fb8a6d0e9ac5bef5584c1aa614d
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2021-08-12 (Thu, 12 Aug 2021)

  Changed paths:
    M clang/lib/Headers/__clang_hip_math.h

  Log Message:
  -----------
  [openmp] Annotate tmp variables with omp_thread_mem_alloc

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.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D107971




More information about the All-commits mailing list