llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.3k stars 11.68k forks source link

[flang][openmp] Bad code for "private" directive with pointers and targets #102939

Open psteinfeld opened 1 month ago

psteinfeld commented 1 month ago

Here's a test program:

program bug
  integer, pointer :: pvar
  integer, target :: tvar
  tvar = 2
  pvar => tvar
  !$omp parallel private (pvar, tvar)
  tvar = 1
  pvar => tvar
  !$omp end parallel
  if (pvar/=2) stop 'fail'
  print *, 'ok'
end program

I compile this program with flang-new -fopenmp bug.f90. When I execute it, I get the output:

Fortran STOP: fail
IEEE arithmetic exceptions signaled: INEXACT

When I compile and execute the same program with gfortran -fopenmp bug.f90, I get the output:

ok
llvmbot commented 1 month ago

@llvm/issue-subscribers-bug

Author: Pete Steinfeld (psteinfeld)

Here's a test program: ``` program bug integer, pointer :: pvar integer, target :: tvar tvar = 2 pvar => tvar !$omp parallel private (pvar, tvar) tvar = 1 pvar => tvar !$omp end parallel if (pvar/=2) stop 'fail' print *, 'ok' end program ``` I compile this program with `flang-new -fopenmp bug.f90`. When I execute it, I get the output: ``` Fortran STOP: fail IEEE arithmetic exceptions signaled: INEXACT ``` When I compile and execute the same program with `gfortran -fopenmp bug.f90`, I get the output: ``` ok ```
tblah commented 2 weeks ago

See https://discourse.llvm.org/t/rfc-openmp-fix-issue-in-mlir-to-llvmir-translation-for-delayed-privatisation/81225