llvm-project
01c2cd3a - [flang][OpenMP] Fix EQUIVALENCE variable privatization in OpenMP (#197726)

Commit
3 days ago
[flang][OpenMP] Fix EQUIVALENCE variable privatization in OpenMP (#197726) Fixes #197553 EQUIVALENCE aliases are lowered with `fir.ptr` addresses (`castAliasToPointer` in ConvertVariable.cpp) to inform alias analysis. However, `privatizeSymbol()` in Utils.cpp treated all `fir::PointerType` values as true Fortran POINTERs, skipping the `unwrapRefType` that computes the correct allocation type. For arrays, this caused the privatizer to allocate pointer-sized storage instead of the full array, resulting in stack buffer overflows at runtime. The fix adds a `!semantics::IsPointer()` check so that only true Fortran POINTERs preserve the `fir.ptr` wrapping. EQUIVALENCE aliases are correctly unwrapped to their underlying type. **Changes:** - flang/lib/Lower/Support/Utils.cpp: Gate the `PointerType` guard on `semantics::IsPointer` to distinguish true POINTERs from EQUIVALENCE aliases - flang/test/Lower/OpenMP/DelayedPrivatization/equivalence.f90: Update existing test to match corrected output (alloc type is now `f32`, not `fir.ptr<f32>`) - flang/test/Lower/OpenMP/lastprivate-equivalence.f90: New test for EQUIVALENCE'd array with lastprivate, verifying correct allocation, deallocation, and writeback
Author
Parents
Loading