[flang-commits] [flang] [flang] Disable Fortran free form line continuation in non-source lin… (PR #94663)
Ye Luo via flang-commits
flang-commits at lists.llvm.org
Thu Jun 6 20:04:49 PDT 2024
ye-luo wrote:
I'm testing this patch `macro_omp.f90`
```
#if defined(_OPENMP)
#define DEVOMP !$omp
#else
#define DEVOMP !!!
#endif
program omp
implicit none
integer i,j
j = 0
DEVOMP parallel &
DEVOMP &do &
DEVOMP & reduction(+:j)
do i =1, 10
j=j+i
end do
DEVOMP parallel &
DEVOMP do &
DEVOMP reduction(+:j)
do i =1, 10
j=j+i
end do
write(*,*) "expect 100 ans = ", j
end program
```
`flang-new -cpp -fopenmp -E` and `flang-new -cpp -E` got me desired output. That is good.
However, I'm hitting a very strange issue. When I do `flang-new -cpp -fopenmp`, I got error
```
yeluo at epyc-server:~$ flang-new -v -cpp -fopenmp macro_omp.f90
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git df6139812aac8ecfa342dbcb277a9e12a9693db2)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/llvm/main-patched/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda-12.3, version 12.3
Found HIP installation: /opt/rocm-6.1.0, version 6.1.40091
"/soft/llvm/main-patched/bin/flang-new" -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -cpp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -fopenmp -resource-dir /soft/llvm/main-patched/bin/.. -mframe-pointer=all -o /tmp/macro_omp-a30508.o -x f95-cpp-input macro_omp.f90
error: Could not parse macro_omp.f90
./macro_omp.f90:12:18: error: expected end of line
DEVOMP parallel &
^
./macro_omp.f90:12:2: in the context: OpenMP construct
DEVOMP parallel &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:12:2: in the context: execution part construct
DEVOMP parallel &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:13:9: error: expected 'END'
DEVOMP &do &
^
./macro_omp.f90:13:2: in the context: execution part construct
DEVOMP &do &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:13:10: error: expected OpenMP construct
DEVOMP &do &
^
./macro_omp.f90:13:2: in the context: OpenMP construct
DEVOMP &do &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:13:2: in the context: execution part construct
DEVOMP &do &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:14:9: error: expected 'END'
DEVOMP & reduction(+:j)
^
./macro_omp.f90:14:2: in the context: execution part construct
DEVOMP & reduction(+:j)
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:14:10: error: expected OpenMP construct
DEVOMP & reduction(+:j)
^
./macro_omp.f90:14:2: in the context: OpenMP construct
DEVOMP & reduction(+:j)
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:14:2: in the context: execution part construct
DEVOMP & reduction(+:j)
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:19:18: error: expected end of line
DEVOMP parallel &
^
./macro_omp.f90:19:2: in the context: OpenMP construct
DEVOMP parallel &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:19:2: in the context: execution part construct
DEVOMP parallel &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:20:12: error: expected end of line
DEVOMP do &
^
./macro_omp.f90:20:2: in the context: OpenMP construct
DEVOMP do &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:20:2: in the context: execution part construct
DEVOMP do &
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:21:9: error: expected 'END'
DEVOMP reduction(+:j)
^
./macro_omp.f90:21:2: in the context: execution part construct
DEVOMP reduction(+:j)
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
./macro_omp.f90:21:10: error: expected OpenMP construct
DEVOMP reduction(+:j)
^
./macro_omp.f90:21:2: in the context: OpenMP construct
DEVOMP reduction(+:j)
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:21:2: in the context: execution part construct
DEVOMP reduction(+:j)
^^^^^^
./macro_omp.f90:2:16: in a macro defined here
#define DEVOMP !$omp
^^^^^
that expanded to:
!$omp
^
./macro_omp.f90:11:2: in the context: execution part
j = 0
^
./macro_omp.f90:7:1: in the context: main program
program omp
^
```
The error went crazy.
However, if I extract preprocessed file `flang-new -cpp -fopenmp -E macro_omp.f90 >& macro_omp_cpp.f90`
```
#line "./macro_omp.f90" 7
program omp
implicit none
integer i,j
j = 0
!$omp parallel &
!$omp &do &
!$omp & reduction(+:j)
do i =1, 10
j=j+i
end do
!$omp parallel &
!$omp do &
!$omp reduction(+:j)
do i =1, 10
j=j+i
end do
write(*,*) "expect 100 ans = ", j
end program
```
and then `flang-new -fopenmp macro_omp_cpp.f90`, I got no error.
I also noticed the compiler seems behavior non-deterministicly when running `flang-new -cpp -fopenmp macro_omp_cpp.f90`. It actually succeeds sometimes but hard to reproduce. I'm wondering if the compiler is affected by uninitialized values.
https://github.com/llvm/llvm-project/pull/94663
More information about the flang-commits
mailing list