llvm / llvm-project

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

[Flang][OpenMP] Compilation error of a threadprivate directive with a variable declared implicitly in main program #82942

Open yus3710-fj opened 6 months ago

yus3710-fj commented 6 months ago

This is an issue from Fujitsu testsuite.

Flang-new terminates abnormally when compiling a threadprivate directive with a variable declared implicitly in main program. The variable in a threadprivate directive must have the SAVE attribute, and the variable declared in main program has it implicitly since Fortran 2008. (So it might not be an OpenMP issue.)

The following are the test program and the compilation results of flang-new and gfortran.

! test.f90
!$OMP THREADPRIVATE(a1)
end
$ flang-new -v test.f90 -fopenmp
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844)
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
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-7f2318.o -x f95-cpp-input test.f90

fatal internal error: SemanticsContext::FindScope(): invalid source location for 'threadprivate(a1)'
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /path/to/install/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-7f2318.o -x f95-cpp-input test.f90
 #0 0x0000ffffb9936dc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/install/lib/libLLVMSupport.so.19git+0x1a6dc8)
 #1 0x0000ffffb9934cf8 llvm::sys::RunSignalHandlers() (/path/to/install/lib/libLLVMSupport.so.19git+0x1a4cf8)
 #2 0x0000ffffb9934e7c SignalHandler(int) Signals.cpp:0:0
 #3 0x0000ffffbc3007a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000ffffb9386274 raise (/lib64/libc.so.6+0x36274)
 #5 0x0000ffffb9370a2c abort (/lib64/libc.so.6+0x20a2c)
 #6 0x0000ffffb09b241c (/path/to/install/lib/libFortranCommon.so.19git+0x241c)
 #7 0x0000ffffb4900fac (/path/to/install/lib/libFortranSemantics.so.19git+0x2140fac)
 #8 0x0000ffffb481ecf8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&)>, std::tuple<std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&>, std::integer_sequence<unsigned long, 4ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205ecf8)
 #9 0x0000ffffb481df68 void Fortran::parser::ForEachInTuple<0ul, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&), std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)) (/path/to/install/lib/libFortranSemantics.so.19git+0x205df68)
#10 0x0000ffffb481e6d8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&)>, std::tuple<std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&>, std::integer_sequence<unsigned long, 0ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205e6d8)
#11 0x0000ffffb4815c2c Fortran::semantics::ResolveOmpParts(Fortran::semantics::SemanticsContext&, Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x2055c2c)
#12 0x0000ffffb489070c Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d070c)
#13 0x0000ffffb4891024 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d1024)
#14 0x0000ffffb4904b44 Fortran::semantics::Semantics::Perform() (/path/to/install/lib/libFortranSemantics.so.19git+0x2144b44)
#15 0x0000ffffba7b2b34 Fortran::frontend::FrontendAction::runSemanticChecks() (/path/to/install/lib/libflangFrontend.so.19git+0x192b34)
#16 0x0000ffffba86f108 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/path/to/install/lib/libflangFrontend.so.19git+0x24f108)
#17 0x0000ffffba7b2180 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/path/to/install/lib/libflangFrontend.so.19git+0x192180)
#18 0x0000ffffba7a63f8 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/install/lib/libflangFrontend.so.19git+0x1863f8)
#19 0x0000ffffbad25020 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/install/lib/libflangFrontendTool.so.19git+0x5020)
#20 0x0000000000405eb8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/install/bin/flang-new+0x405eb8)
#21 0x0000000000404ae0 main (/path/to/install/bin/flang-new+0x404ae0)
#22 0x0000ffffb9374384 __libc_start_main (/lib64/libc.so.6+0x24384)
#23 0x0000000000404d28 _start (/path/to/install/bin/flang-new+0x404d28)
flang-new: error: unable to execute command: Aborted (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
flang-new: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-new: note: diagnostic msg: /tmp/test-7c97df
flang-new: note: diagnostic msg: /tmp/test-7c97df.sh
flang-new: note: diagnostic msg: 

********************
$ gfortran-13.2 test.f90 -fopenmp
$

If the variable is declared explicitly, the compilation succeeds.

$ cat test2.f90 
real a1
!$OMP THREADPRIVATE(a1)
end
$ flang-new test2.f90 -fopenmp
$ 
llvmbot commented 6 months ago

@llvm/issue-subscribers-flang-frontend

Author: Yusuke MINATO (yus3710-fj)

This is an issue from Fujitsu testsuite. Flang-new terminates abnormally when compiling a `threadprivate` directive with a variable declared implicitly in main program. The variable in a `threadprivate` directive must have the `SAVE` attribute, and the variable declared in main program has it implicitly since Fortran 2008. (So it might not be an OpenMP issue.) The following are the test program and the compilation results of flang-new and gfortran. ```fortran ! test.f90 !$OMP THREADPRIVATE(a1) end ``` ```console $ flang-new -v test.f90 -fopenmp flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844) 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 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-7f2318.o -x f95-cpp-input test.f90 fatal internal error: SemanticsContext::FindScope(): invalid source location for 'threadprivate(a1)' PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: /path/to/install/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-7f2318.o -x f95-cpp-input test.f90 #0 0x0000ffffb9936dc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/install/lib/libLLVMSupport.so.19git+0x1a6dc8) #1 0x0000ffffb9934cf8 llvm::sys::RunSignalHandlers() (/path/to/install/lib/libLLVMSupport.so.19git+0x1a4cf8) #2 0x0000ffffb9934e7c SignalHandler(int) Signals.cpp:0:0 #3 0x0000ffffbc3007a0 (linux-vdso.so.1+0x7a0) #4 0x0000ffffb9386274 raise (/lib64/libc.so.6+0x36274) #5 0x0000ffffb9370a2c abort (/lib64/libc.so.6+0x20a2c) #6 0x0000ffffb09b241c (/path/to/install/lib/libFortranCommon.so.19git+0x241c) #7 0x0000ffffb4900fac (/path/to/install/lib/libFortranSemantics.so.19git+0x2140fac) #8 0x0000ffffb481ecf8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&)>, std::tuple<std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&>, std::integer_sequence<unsigned long, 4ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct>(std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::parser::OpenMPDeclarativeAllocate, Fortran::parser::OpenMPDeclareReductionConstruct, Fortran::parser::OpenMPDeclareSimdConstruct, Fortran::parser::OpenMPDeclareTargetConstruct, Fortran::parser::OpenMPThreadprivate, Fortran::parser::OpenMPRequiresConstruct> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205ecf8) #9 0x0000ffffb481df68 void Fortran::parser::ForEachInTuple<0ul, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&), std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>>(std::tuple<std::__cxx11::list<Fortran::parser::OpenACCDeclarativeConstruct, std::allocator<Fortran::parser::OpenACCDeclarativeConstruct>>, std::__cxx11::list<Fortran::parser::OpenMPDeclarativeConstruct, std::allocator<Fortran::parser::OpenMPDeclarativeConstruct>>, std::__cxx11::list<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, std::allocator<Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::UseStmt, false>>>>, std::__cxx11::list<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>, std::allocator<Fortran::parser::Statement<Fortran::common::Indirection<Fortran::parser::ImportStmt, false>>>>, Fortran::parser::ImplicitPart, std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)) (/path/to/install/lib/libFortranSemantics.so.19git+0x205df68) #10 0x0000ffffb481e6d8 std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<void (*)(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&)>, std::tuple<std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&>, std::integer_sequence<unsigned long, 0ul>>::__visit_invoke(void Fortran::parser::Walk<Fortran::semantics::OmpAttributeVisitor, Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>>(std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&, Fortran::semantics::OmpAttributeVisitor&)::'lambda'(Fortran::semantics::OmpAttributeVisitor const&)&&, std::variant<Fortran::common::Indirection<Fortran::parser::MainProgram, false>, Fortran::common::Indirection<Fortran::parser::FunctionSubprogram, false>, Fortran::common::Indirection<Fortran::parser::SubroutineSubprogram, false>, Fortran::common::Indirection<Fortran::parser::Module, false>, Fortran::common::Indirection<Fortran::parser::Submodule, false>, Fortran::common::Indirection<Fortran::parser::BlockData, false>, Fortran::common::Indirection<Fortran::parser::CompilerDirective, false>, Fortran::common::Indirection<Fortran::parser::OpenACCRoutineConstruct, false>> const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x205e6d8) #11 0x0000ffffb4815c2c Fortran::semantics::ResolveOmpParts(Fortran::semantics::SemanticsContext&, Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x2055c2c) #12 0x0000ffffb489070c Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d070c) #13 0x0000ffffb4891024 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/path/to/install/lib/libFortranSemantics.so.19git+0x20d1024) #14 0x0000ffffb4904b44 Fortran::semantics::Semantics::Perform() (/path/to/install/lib/libFortranSemantics.so.19git+0x2144b44) #15 0x0000ffffba7b2b34 Fortran::frontend::FrontendAction::runSemanticChecks() (/path/to/install/lib/libflangFrontend.so.19git+0x192b34) #16 0x0000ffffba86f108 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/path/to/install/lib/libflangFrontend.so.19git+0x24f108) #17 0x0000ffffba7b2180 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/path/to/install/lib/libflangFrontend.so.19git+0x192180) #18 0x0000ffffba7a63f8 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/install/lib/libflangFrontend.so.19git+0x1863f8) #19 0x0000ffffbad25020 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/install/lib/libflangFrontendTool.so.19git+0x5020) #20 0x0000000000405eb8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/install/bin/flang-new+0x405eb8) #21 0x0000000000404ae0 main (/path/to/install/bin/flang-new+0x404ae0) #22 0x0000ffffb9374384 __libc_start_main (/lib64/libc.so.6+0x24384) #23 0x0000000000404d28 _start (/path/to/install/bin/flang-new+0x404d28) flang-new: error: unable to execute command: Aborted (core dumped) flang-new: error: flang frontend command failed due to signal (use -v to see invocation) flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git db8b76dbb07d4053a4e44baf1518c9ea0d84c844) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /path/to/install/bin flang-new: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: flang-new: note: diagnostic msg: /tmp/test-7c97df flang-new: note: diagnostic msg: /tmp/test-7c97df.sh flang-new: note: diagnostic msg: ******************** ``` ```console $ gfortran-13.2 test.f90 -fopenmp $ ``` If the variable is declared explicitly, the compilation succeeds. ```console $ cat test2.f90 real a1 !$OMP THREADPRIVATE(a1) end $ flang-new test2.f90 -fopenmp $ ```
harishch4 commented 3 months ago

Is this issue still present?, current flang-new seems to handle this:https://godbolt.org/z/nfoqh8ddz

yus3710-fj commented 3 months ago

Thank you for the information. Your test code includes PROGRAM statement. Flang-new had already worked as expected for such a code even before I reported this issue. However, flang-new hasn't worked for the original program I wrote in the description yet.

kiranktp commented 3 months ago

@Thirumalai-Shaktivel [AMD] is looking into this issue.

Thirumalai-Shaktivel commented 2 months ago

This issue is fixed and is under internal review.