Closed
Description
Breakage happens between e3ffc4b good and c8dc6b5 bad.
repro.f90
program main
implicit none
integer :: ns
REAL(8) :: etetra(4), dosint0(2)
!$omp parallel reduction(+:dosint0) private(ns)
DO ns = 1, 3
enddo
!$omp end parallel
endprogram
flang-new -fopenmp -O0 repro.f90 # works
flang-new -fopenmp -O3 repro.f90
flang-new: /vast/users/yeluo/opt/llvm-clang/llvm-project-nightly/llvm/lib/IR/Instruction.cpp:132: BasicBlock::iterator llvm::Instruction::insertInto(BasicBlock *, BasicBlock::iterator): Assertion `(It == ParentBB->end() || It->getParent() == ParentBB) && "It not in ParentBB"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /soft/compilers/llvm/main-20240528/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -fversion-loops-for-stride -fopenmp -resource-dir /soft/compilers/llvm/main-20240528/bin/.. -mframe-pointer=none -O3 -o /tmp/repro-53af4b.o -x f95-cpp-input repro.f90
#0 0x000055e54b52f588 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x2acd588)
#1 0x000055e54b52d05e llvm::sys::RunSignalHandlers() (/soft/compilers/llvm/main-20240528/bin/flang-new+0x2acb05e)
#2 0x000055e54b52fd6d SignalHandler(int) Signals.cpp:0:0
#3 0x00007f16f7e83910 __restore_rt (/lib64/libpthread.so.0+0x16910)
#4 0x00007f16f77b1d2b raise (/lib64/libc.so.6+0x4ad2b)
#5 0x00007f16f77b33e5 abort (/lib64/libc.so.6+0x4c3e5)
#6 0x00007f16f77a9c6a __assert_fail_base (/lib64/libc.so.6+0x42c6a)
#7 0x00007f16f77a9cf2 (/lib64/libc.so.6+0x42cf2)
#8 0x000055e54fb637af (/soft/compilers/llvm/main-20240528/bin/flang-new+0x71017af)
#9 0x000055e54d9a0378 llvm::IRBuilderCallbackInserter::InsertHelper(llvm::Instruction*, llvm::Twine const&, llvm::BasicBlock*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true>, false, false>) const (/soft/compilers/llvm/main-20240528/bin/flang-new+0x4f3e378)
#10 0x000055e549f74679 llvm::IRBuilderBase::CreateAlloca(llvm::Type*, llvm::Value*, llvm::Twine const&) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x1512679)
#11 0x000055e54ce282da void llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>::callback_fn<convertOmpParallel(mlir::omp::ParallelOp, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&)::$_1>(long, llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint) OpenMPToLLVMIRTranslation.cpp:0:0
#12 0x000055e54eda36a1 llvm::OpenMPIRBuilder::createParallel(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::IRBuilderBase::InsertPoint, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>, llvm::function_ref<llvm::IRBuilderBase::InsertPoint (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::Value&, llvm::Value&, llvm::Value*&)>, std::function<void (llvm::IRBuilderBase::InsertPoint)>, llvm::Value*, llvm::Value*, llvm::omp::ProcBindKind, bool) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x63416a1)
#13 0x000055e54ce15881 convertHostOrTargetOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#14 0x000055e54d996741 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x4f34741)
#15 0x000055e54d996f5c mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x4f34f5c)
#16 0x000055e54d99a6cf mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x4f386cf)
#17 0x000055e54d99c79a mlir::LLVM::ModuleTranslation::convertFunctions() (/soft/compilers/llvm/main-20240528/bin/flang-new+0x4f3a79a)
#18 0x000055e54d99ebf6 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x4f3cbf6)
#19 0x000055e54b7b5b1d Fortran::frontend::CodeGenAction::generateLLVMIR() (/soft/compilers/llvm/main-20240528/bin/flang-new+0x2d53b1d)
#20 0x000055e54b7b8ada Fortran::frontend::CodeGenAction::executeAction() (/soft/compilers/llvm/main-20240528/bin/flang-new+0x2d56ada)
#21 0x000055e54b57728c Fortran::frontend::FrontendAction::execute() (/soft/compilers/llvm/main-20240528/bin/flang-new+0x2b1528c)
#22 0x000055e54b560e42 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x2afee42)
#23 0x000055e54b57b4e8 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x2b194e8)
#24 0x000055e549ec49e1 fc1_main(llvm::ArrayRef<char const*>, char const*) (/soft/compilers/llvm/main-20240528/bin/flang-new+0x14629e1)
#25 0x000055e549ec306b main (/soft/compilers/llvm/main-20240528/bin/flang-new+0x146106b)
#26 0x00007f16f779c24d __libc_start_main (/lib64/libc.so.6+0x3524d)
#27 0x000055e549ec2b1a _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
flang-new: error: unable to execute command: Aborted