[all-commits] [llvm/llvm-project] fdfdcb: [Flang][MLIR][OpenMP] Fix declare_target globals v...

Sergio Afonso via All-commits all-commits at lists.llvm.org
Wed Jul 8 02:56:47 PDT 2026


  Branch: refs/heads/users/skatrak/host-filtering-01-globals
  Home:   https://github.com/llvm/llvm-project
  Commit: fdfdcb6a697d349581c932a7fcb7b46ab2cee448
      https://github.com/llvm/llvm-project/commit/fdfdcb6a697d349581c932a7fcb7b46ab2cee448
  Author: Sergio Afonso <Sergio.AfonsoFumero at amd.com>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    M flang/lib/Optimizer/OpenMP/HostOpFiltering.cpp
    M flang/test/Transforms/OpenMP/function-filtering-host-ops.mlir
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    A mlir/test/Target/LLVMIR/omptarget-declare-target-all-device-types-device.mlir
    M mlir/test/Target/LLVMIR/omptarget-declare-target-llvm-device.mlir

  Log Message:
  -----------
  [Flang][MLIR][OpenMP] Fix declare_target globals visibility

This patch introduces various changes to the handling of
`declare_target` global variables in Flang:
- Non-`declare_target` globals are unconditionally made "internal" when
  compiling for an OpenMP offload target. This prevents potential symbol
  redefinition issues related to globals that don't actually exist on the
  device.
- Local SAVE variables handling for OpenMP offloading programs is fixed to
  prevent their associated "internal" linkage from producing broken
  device code for `declare_target enter(...)`.
- When globals are indirectly accessed from the target device (e.g.
  `declare_target link(...)`), the associated and unused full-storage
  global is marked with "internal" linkage to facilitate later removal.
- `declare_target device_type(host) enter(...)` variables are set to
  external linkage when compiling for a target device, causing linker
  errors if accessed. This mirrors Clang's behavior.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list