-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Labels
Description
Consider the following test code, derived from a sample CP2K test build:
module test
contains
subroutine omp_master_repro
implicit none
integer, parameter :: nim = 4
integer, parameter :: nvals = 8
integer,target :: ui
integer :: hold1(nvals, nim)
hold1 = 0
!$OMP PARALLEL DEFAULT(NONE) &
!$OMP PRIVATE(ui) &
!$OMP SHARED(hold1, nim)
!$OMP MASTER
do ui = 1, nim
hold1(:, ui) = 1
end do
!$OMP END MASTER
!$OMP END PARALLEL
end subroutine omp_master_repro
end module test
So this is a simple parallel pragma with a master region with a do loop that includes a private target integer. Compiling this with a recent flang, I get a compilation error:
[scamp]$ flang test.F90 -fopenmp -c -O1
/opt/gcc-9.3.0/include/c++/9.3.0/optional:438: constexpr _Tp& std::_Optional_base_impl<_Tp, _Dp>::_M_get() [with _Tp = llvm::StringRef; _Dp = std::_Optional_base<llvm::StringRef, true, true>]: Assertion 'this->_M_is_engaged()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: flang -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -fopenmp -resource-dir ./lib/clang/22 -mframe-pointer=none -O1 -o test.o -x f95 test.F90
#0 0x0000000005576ff8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./bin/flang+0x5576ff8)
#1 0x0000000005573e94 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x00007f280d225990 __restore_rt (/lib64/libpthread.so.0+0x12990)
#3 0x00007f280bfff52f raise (/lib64/libc.so.6+0x4e52f)
#4 0x00007f280bfd2e65 abort (/lib64/libc.so.6+0x21e65)
#5 0x0000000004e85e02 (./bin/flang+0x4e85e02)
#6 0x00000000069dd84a (anonymous namespace)::AddAliasTagsPass::runOnAliasInterface(fir::FirAliasTagOpInterface, (anonymous namespace)::PassState&) AddAliasTags.cpp:0:0
#7 0x00000000069d13bc void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.1) AddAliasTags.cpp:0:0
#8 0x00000000069d13bc void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.1) AddAliasTags.cpp:0:0
#9 0x00000000069d13bc void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.1) AddAliasTags.cpp:0:0
#10 0x00000000069de25f (anonymous namespace)::AddAliasTagsPass::runOnOperation() AddAliasTags.cpp:0:0
#11 0x000000000bdb4021 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./bin/flang+0xbdb4021)
#12 0x000000000bdb4357 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./bin/flang+0xbdb4357)
#13 0x000000000bdb61aa mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (./bin/flang+0xbdb61aa)
#14 0x000000000bdb6fe6 mlir::PassManager::run(mlir::Operation*) (./bin/flang+0xbdb6fe6)
#15 0x00000000055e0a24 Fortran::frontend::CodeGenAction::generateLLVMIR() (./bin/flang+0x55e0a24)
#16 0x00000000055e6258 Fortran::frontend::CodeGenAction::executeAction() (./bin/flang+0x55e6258)
#17 0x00000000055c6fed Fortran::frontend::FrontendAction::execute() (./bin/flang+0x55c6fed)
#18 0x00000000055a0bdb Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (./bin/flang+0x55a0bdb)
#19 0x00000000055cffb7 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (./bin/flang+0x55cffb7)
#20 0x0000000004e87e8b fc1_main(llvm::ArrayRef<char const*>, char const*) (./bin/flang+0x4e87e8b)
#21 0x0000000004e875f0 main (./bin/flang+0x4e875f0)
#22 0x00007f280bfeb7e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)
#23 0x0000000004e85cee _start (./bin/flang+0x4e85cee)
flang-22: error: unable to execute command: Aborted (core dumped)
flang-22: error: flang frontend command failed due to signal (use -v to see invocation)
From our regression testing, we know this built successfully before f57abf5 and started failing after 794551d. I'm suspicious of the change from @tblah for #170908 - because if I make the ui variable not a target, then the problem disappears.
However, in that hash bisection, #171702, #170734, and #171845 also touch Flang OpenMP things - but none of them are really suspcious looking to me. So I think this is caused by the target change.