[all-commits] [llvm/llvm-project] e34e31: [clang][OpenMP] Cast by-reference captures to the ...

Akash Manna via All-commits all-commits at lists.llvm.org
Fri Sep 25 03:46:51 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e34e31190233a5733d6b7751160a29e50cd8b41c
      https://github.com/llvm/llvm-project/commit/e34e31190233a5733d6b7751160a29e50cd8b41c
  Author: Akash Manna <akash.manna.mymail at gmail.com>
  Date:   2026-09-25 (Fri, 25 Sep 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/lib/CodeGen/CGStmtOpenMP.cpp
    A clang/test/OpenMP/target_map_address_space_codegen.c

  Log Message:
  -----------
  [clang][OpenMP] Cast by-reference captures to the address space of the captured field (#226229)

Fixes #140069

Sema strips all qualifiers, including the address space, from the type
of a variable captured by an OpenMP region, so the outlined function for
a `target` region takes `int __seg_gs a;` as a plain `int &`, i.e. a
pointer in the default address space. That is the intended model: inside
the region the variable is an ordinary object, and the host's segment
address space means nothing on a device. `GenerateOpenMPCapturedVars`
ignored the captured field's type for by-reference captures though, and
passed the variable's own address. With `map(alloc: a)` that is a `ptr
addrspace(256)` argument for a `ptr` parameter, and emitting the host
fallback call tripped the "Calling a function with a bad signature"
assertion. The same call is emitted on the `omp_offload.failed` path
when offloading targets are given, so this wasn't limited to host-only
compiles.

By-reference captures now convert the address to the type of the
captured field, adding an `addrspacecast` only when the address spaces
differ. On x86 the cast doesn't change the pointer value, so the region
gets the linear address of the object, which is also what the mapping
passes to the runtime and what GCC does for the same code. Captures
whose address already has the right type are untouched.



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