[flang-commits] [flang] [flang][pft] visit original symbol in acc use_device (PR #194588)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Tue Apr 28 06:23:05 PDT 2026
================
@@ -2221,6 +2221,25 @@ struct SymbolVisitor {
return false;
}
+ bool Pre(const Fortran::parser::AccClause::UseDevice &useDevice) {
+ // For use_device, each symbol's parser Name has been given a local copy
+ // of the symbol with the DEVICE attribute. The original symbol will be
+ // needed in lowering and may not appear in the parse tree of the function
+ // anymore. Visit it now: it is not directly accessible from the construct
+ // symbol, so the parent scope must be searched to find it.
+ for (const auto &accObject : useDevice.v.v) {
+ if (const semantics::Symbol *deviceSym =
+ Fortran::parser::GetFirstName(accObject).symbol) {
+ if (const semantics::Symbol *hostSym =
+ deviceSym->owner().parent().FindSymbol(deviceSym->name()))
----------------
eugeneepshteyn wrote:
Question:
```
module m
real :: a(100)
contains
subroutine s
block
integer :: a(50) ! shadows module a in this block
!$acc host_data use_device(a) ! must instantiate the right 'a'
!$acc end host_data
end block
end subroutine
end module
```
Will this get to the correct `a`? I assume it should find `integer :: a(50)`.
https://github.com/llvm/llvm-project/pull/194588
More information about the flang-commits
mailing list