llvm / llvm-project

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

[Flang] Compilation error of FORALL statement #65244

Closed ohno-fj closed 10 months ago

ohno-fj commented 1 year ago
Version of flang-new : 18.0.0(c07062a2e9bf9aa1211b958f6bb4c5746139c180)

Program using FORALL statement such as the following results in a compile-time error. If the -flang-experimental-hlfir option is specified, Flang-new can compile successfully.

The following are the test program, Flang-new, Gfortran and ifort compilation result.

snggm306_5.f90:

program main
  character(10):: text
  integer      :: i
  do kk=1,10
     text(kk:kk)='x'
  end do
  text(10:10)=achar(9)
  forall (i=1:10, text(i:i) == achar(9)) text(i:i)=' '
  print *,'pass'
end program main
$ flang-new snggm306_5.f90
error: loc("/home/ohno/tp/reproducerJ/Metro/F200X01/snggm306_5.f90":8:3): 'fir.result' op must be the last operation in the parent block
error: verification of lowering to FIR failed
$
$ flang-new snggm306_5.f90 -flang-experimental-hlfir
$
$ gfortran snggm306_5.f90
$
$ ifort snggm306_5.f90
$
llvmbot commented 1 year ago

@llvm/issue-subscribers-flang-frontend

llvmbot commented 1 year ago

@llvm/issue-subscribers-bug

yus3710-fj commented 10 months ago

This issue isn't reproduced now because HLFIR is enabled by default.

$ flang-new -v snggm306_5.f90
flang-new version 18.0.0 (https://github.com/llvm/llvm-project.git ba89749cd24950c9c51f4cc64277ce0421d86d20)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
 :
$