[all-commits] [llvm/llvm-project] 2bf008: [clang][OpenMP] Fix crashes on target regions insi...

Akash Manna via All-commits all-commits at lists.llvm.org
Tue Sep 29 06:51:39 PDT 2026


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

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/lib/CodeGen/CGStmtOpenMP.cpp
    M clang/lib/Sema/SemaOpenMP.cpp
    A clang/test/OpenMP/target_global_ref_namespace_scope_lambda.cpp
    A clang/test/OpenMP/target_global_ref_namespace_scope_lambda_codegen.cpp

  Log Message:
  -----------
  [clang][OpenMP] Fix crashes on target regions inside namespace-scope lambdas and blocks (#226691)

Fixes #223397

A `target` region inside a lambda or block at namespace scope crashed
clang in two places. In Sema, `isOpenMPCapturedDecl` decides whether a
global must be captured by walking the function scope stack down to the
innermost OpenMP captured region, stopping at an ordinary function
scope. The capture initializers of a directive's outermost region are
built after all of its regions have been popped. Inside a function that
walk ends at the function's scope, but a namespace-scope lambda or block
has nothing underneath it, so the walk ran off the stack and asserted.
This happens for any global reference, such as `int &r = x; auto l = []
{ #pragma omp target r = 1; };`. The self-referential declaration in the
report is incidental. Once past Sema, CodeGen asserted too: it names the
outlined kernel after the region's parent function, and such a region
has none, even without a reference.

In Sema, running out of scopes now means the same as reaching a function
scope, so the variable is not captured from the current scope. That is
what the same lambda already gets inside a function. In CodeGen, a
region with no parent function is named after the function being
emitted.



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