[flang-commits] [flang] [flang][OpenMP] Fix common block missing symbol crash (PR #67330)

via flang-commits flang-commits at lists.llvm.org
Mon Sep 25 06:49:12 PDT 2023


NimishMishra wrote:

The `copyHostAssociateVar` function captures two symbol boxes: one from `lookupOneLevelUpSymbol` which fetches the original copy of the variable, and one from `shallowLookupSymbol` which fetches the copy that intends to mask the original variable.

However, in case of common block, because of the abstraction involved, there is a chance that `shallowLookupSymbol` fails to find a symbol box because relevant symbol mapping has not been created. For instance,

```
  program sample
  integer:: x
  integer :: y
  common /blk/ x
  !$omp threadprivate (/blk/)
  !$omp parallel sections copyin(/blk/)
    !$omp section
      y = y + 1
  !$omp end parallel sections
 end program sample
```

Dumping the parse-tree for parallel sections reveals that `x` is not explicitly used in the construct, thereby it being missing from the symbol map of the construct. Now when copyin executes, it fails to find `x` in the inner construct's symbol map, thereby erring out a `LLVM ERROR: symbol not mapped`. This PR fixes the same. It only executes the relevant copyin functionality iff it is sure that the symbol exists in the symbol map of the inner construct (i.e. the relevant variable is used in the inner construct).

https://github.com/llvm/llvm-project/pull/67330


More information about the flang-commits mailing list