-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
Reproducer: https://github.com/fujitsu/compiler-test-suite/blob/main/Fortran/1052/1052_0120.f
It doesn't reproduce in all environments, but I was able to reproduce it on AMD EPYC 9334 host running Rocky Linux 9.4.
To reproduce:
$ flang -fopenmp -march=native -O2 -frtlib-add-rpath 1052_0120.f && ./a.out
Segmentation fault (core dumped)
The issue seems to be that flang doesn't support any way to request array buffer alignment. In the reproducer there are the following declarations:
real*8,target:: a(100)
real*8,target:: b(100)
!dec$ attributes align:64::a
!dec$ attributes align:64::b
Later in the code, there's this statement: !$omp simd aligned(aa,bb)
The alignment is not specified, so per OpenMP 6.0 spec, 7.12, "If the alignment modifier is not specified, implementation defined default alignments for SIMD instructions on the target platforms are assumed." (Perhaps that's where 512
alignment used below comes from.)
The alignment attributes are parsed, but don't have any effect (or at least don't have a consistent effect). Here's the IR, generated by flang -fopenmp -march=native -O2 -S -emit-llvm 1052_0120.f
:
...
12 @_QFEa = internal global [100 x double] zeroinitializer, align 64
...
14 @_QFEb = internal global [100 x double] zeroinitializer
...
67 call void @llvm.assume(i1 true) [ "align"(ptr @_QFEa, i64 512) ]
68 call void @llvm.assume(i1 true) [ "align"(ptr @_QFEb, i64 512) ]
...
Somehow a
got alignment of 64, but not b
. (This could be some LLVM optimization passes "inventing" alignment. If you generate LLVM IR at -O0
, neither a
, nor b
globals will have alignment.)
To summarize, there are two issues here: (1) flang has no means to set alignment on arrays and (2) in the process of processing omp aligned simd
the arrays somehow are assumed to be aligned more than they are.
Small reproducer for inability to set alignment:
module align_me
real*8, target :: arr(100)
!dec$ attributes align:64::arr
end module
Resulting LLVM IR has no alignment information for arr
: @_QMalign_meEarr = global [100 x double] zeroinitializer
(HLFIR doesn't seem to have any alignment information either.)
flang version:
flang version 22.0.0git (https://github.com/llvm/llvm-project 9865f7ec2bb15f3d8aa25c7e9305393422597dc5)
Target: x86_64-unknown-linux-gnu
Thread model: posix