[all-commits] [llvm/llvm-project] 1d699b: [OpenMP] Always apply target declarations to canon...

Joseph Huber via All-commits all-commits at lists.llvm.org
Tue Jun 27 07:15:25 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1d699bf2664d2a9e64024fd9eb87451d6360ea8c
      https://github.com/llvm/llvm-project/commit/1d699bf2664d2a9e64024fd9eb87451d6360ea8c
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2023-06-27 (Tue, 27 Jun 2023)

  Changed paths:
    M clang/lib/AST/AttrImpl.cpp
    M clang/test/OpenMP/declare_target_codegen.cpp

  Log Message:
  -----------
  [OpenMP] Always apply target declarations to canonical definitions

This patch changes the handling of OpenMP to add the device attributes
to the canonical definitions when we encounter a non-canonical
definition. Previously, the following code would not work because it
would find the non-canonical definition first which would then not be
used anywhere else.

```
int x;
extern int x;
```

This patch now adds the attribute to both of them. This allows us to
perform the following operation if, for example, there were an
implementation of `stderr` on the device.

```
#include <stdio.h>

// List of libc symbols supported on the device.
extern FILE *stderr;
```

Unfortunately I cannot think of an equivalent solution to HIP / CUDA
device declarations as those are done with simple attributes. Attributes
themselves cannot be used to affect a definition once its canonical
definition has already been seen. Some help on that front would be
appreciated.

Fixes https://github.com/llvm/llvm-project/issues/63355

Reviewed By: ABataev

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




More information about the All-commits mailing list