[all-commits] [llvm/llvm-project] 0db9f5: [flang][OpenACC] Don't rebind construct entities t...

Ron Green [NVIDIA] via All-commits all-commits at lists.llvm.org
Fri Jul 24 10:35:00 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0db9f599c087cf4d6344223d1a62a81d6308c82a
      https://github.com/llvm/llvm-project/commit/0db9f599c087cf4d6344223d1a62a81d6308c82a
  Author: Ron Green [NVIDIA] <rogreen at nvidia.com>
  Date:   2026-07-24 (Fri, 24 Jul 2026)

  Changed paths:
    M flang/lib/Semantics/resolve-directives.cpp
    M flang/test/Lower/OpenACC/acc-loop.f90
    A flang/test/Semantics/OpenACC/acc-construct-entity-shadow.f90

  Log Message:
  -----------
  [flang][OpenACC] Don't rebind construct entities to enclosing variables (#210775)

`AccAttributeVisitor::Post(Name)` "adjusts" every name referenced inside
an OpenACC region to the symbol found in the current scope. A construct
entity -- a `DO CONCURRENT`/`FORALL` index-name, or a variable declared
in a `BLOCK` construct -- lives in its own scope nested within the
region, but the visitor's current scope does not descend into that
construct scope. `FindSymbol` therefore resolves the name to a
like-named variable in an enclosing scope and rebinds the reference to
it.

When such an entity shadows an enclosing DO variable and the loop is
associated with an OpenACC construct, this makes the entity alias that
active DO variable, so referencing or defining it wrongly triggers
"Cannot redefine DO variable" -- even though the code is legal and
compiles without error when OpenACC is disabled. This affected a `DO
CONCURRENT` index-name as well as a variable declared in a `BLOCK`
construct nested in the loop, e.g.:

```fortran
do i = 1, m
  !$acc parallel loop gang vector collapse(2) independent
  do concurrent (j = 1:n, ii = 1:m)
    block
      integer :: i     ! shadows the enclosing `do i`
      i = ii
      a(i,j) = b(i,j)
    end block
  end do
end do
```

Skip the adjustment when the resolved symbol is owned by a scope
contained in the current scope, i.e. it was declared within the region;
name resolution already bound it correctly. The `DO CONCURRENT`
induction variables are then privatized as their own construct-local
entities rather than the shadowed enclosing variable, as reflected in
the updated `acc-loop.f90` lowering test.

Add a Semantics regression test covering the `DO CONCURRENT` and `BLOCK`
cases.



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