[Flang][OpenMP] Compilation error of specifying a pointer in a threadprivate directive
Version of flang-new : 19.0.0(dcebe297367f48a71a5ecea3bcdd54671195da1b)/AArch64
Specifying a pointer in a threadprivate directive results in a compilation-time error.
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
snggz274_.f90:
subroutine ss2
external ::a,x
pointer:: a
!$omp threadprivate(a)
save a
a=>x
call a
end subroutine ss2
subroutine x
end subroutine x
program main
call ss2
print *,'pass'
end program main
$ flang-new -fopenmp snggz274_.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/FFE_2016_V20L30_11/snggz274_.f90":1:1): 'omp.threadprivate' op failed to verify that all of {sym_addr, tls_addr} have same type
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/FFE_2016_V20L30_11/snggz274_.f90":1:1): cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
error: failed to create the LLVM module
$
$ gfortran -fopenmp snggz274_.f90; ./a.out
pass
$
$ ifort -qopenmp -diag-disable=10448 snggz274_.f90; ./a.out
pass
$
@llvm/issue-subscribers-openmp
Author: None (ohno-fj)
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
snggz274_.f90:
subroutine ss2
external ::a,x
pointer:: a
!$omp threadprivate(a)
save a
a=>x
call a
end subroutine ss2
subroutine x
end subroutine x
program main
call ss2
print *,'pass'
end program main
$ flang-new -fopenmp snggz274_.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/FFE_2016_V20L30_11/snggz274_.f90":1:1): 'omp.threadprivate' op failed to verify that all of {sym_addr, tls_addr} have same type
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/FFE_2016_V20L30_11/snggz274_.f90":1:1): cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
error: failed to create the LLVM module
$
$ gfortran -fopenmp snggz274_.f90; ./a.out
pass
$
$ ifort -qopenmp -diag-disable=10448 snggz274_.f90; ./a.out
pass
$
@llvm/issue-subscribers-flang-ir
Author: None (ohno-fj)
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
snggz274_.f90:
subroutine ss2
external ::a,x
pointer:: a
!$omp threadprivate(a)
save a
a=>x
call a
end subroutine ss2
subroutine x
end subroutine x
program main
call ss2
print *,'pass'
end program main
$ flang-new -fopenmp snggz274_.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/FFE_2016_V20L30_11/snggz274_.f90":1:1): 'omp.threadprivate' op failed to verify that all of {sym_addr, tls_addr} have same type
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/FFE_2016_V20L30_11/snggz274_.f90":1:1): cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
error: failed to create the LLVM module
$
$ gfortran -fopenmp snggz274_.f90; ./a.out
pass
$
$ ifort -qopenmp -diag-disable=10448 snggz274_.f90; ./a.out
pass
$
This is working now. @ohno-fj could you please confirm and close?
Thank you for the information, @ceseo. I confirmed that the program works correctly when using flang built on December 16.
$ flang --version
flang version 20.0.0git (https://github.com/llvm/llvm-project.git 8d550aa0f027eb2cf32850f3905dc1db22317587)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/groups/ssoft/compiler/llvm/aarch64/main-20241216-8d550aa0f027/bin
Build config: +assertions
$
$ export OMP_NUM_THREADS=2; flang -fopenmp snggz274_.f90; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
pass
$