Issue 141460
Summary [flang][mlir] compiler crashes in where construct
Labels mlir, flang
Assignees
Reporter shivaramaarao
    consider the following program
``` SUBROUTINE init(p,w,r,t)
IMPLICIT NONE
REAL, INTENT(IN)    :: p
REAL(KIND=4),      INTENT(INOUT) :: w(:,:),r(:,:)
REAL(KIND=4),      INTENT(INOUT) :: t(:)
!
 where(w(:,1)==0.)
    t (:)= 1.0
  elsewhere
    t(:) = r(:,1) / sub(r(:,1))
  end where

CONTAINS
  FUNCTION sub(p1) RESULT(p2)
 IMPLICIT NONE
    REAL, DIMENSION(:), INTENT(IN)  :: p1
    REAL, DIMENSION(SIZE(p1))       :: p2
    p2(:) = p1(:)
  END FUNCTION sub
END SUBROUTINE init ```

when compiled under O2 option, the flang compiler crashes
```  #0 0x000055f5af734532 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/shivaram/llvm_mir_flang/bin/flang+0x1784532)
 #1 0x000055f5af73169f llvm::sys::RunSignalHandlers() (/home/shivaram/llvm_mir_flang/bin/flang+0x178169f)
 #2 0x000055f5af7317e4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f639a448520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f639a49c9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f639a49c9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f639a49c9fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f639a448476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f639a42e7f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f639a42e71b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f639a43fe96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000055f5b53c265d mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const PatternMatch.cpp:0:0
#12 0x000055f5b53c136a mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const PatternMatch.cpp:0:0
#13 0x000055f5b53c136a mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const PatternMatch.cpp:0:0
#14 0x000055f5b53c136a mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const PatternMatch.cpp:0:0
#15 0x000055f5b53c0334 mlir::RewriterBase::eraseOp(mlir::Operation*) (/home/shivaram/llvm_mir_flang/bin/flang+0x7410334)
#16 0x000055f5b3744c50 mlir::detail::ConversionPatternRewriterImpl::applyRewrites() (/home/shivaram/llvm_mir_flang/bin/flang+0x5794c50)
#17 0x000055f5b376208f mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/home/shivaram/llvm_mir_flang/bin/flang+0x57b208f)
#18 0x000055f5b3764839 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/home/shivaram/llvm_mir_
lang/bin/flang+0x57b4839)
#19 0x000055f5b0693c14 (anonymous namespace)::LowerHLFIROrderedAssignments::runOnOperation() LowerHLFIROrderedAssignments.cpp:0:0
#20 0x000055f5b515161e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/shivaram/llvm_mir_flang/bin/flang+0x71a161e)
#21 0x000055f5b5151ab0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassIn
trumentation::PipelineParentInfo const*) (/home/shivaram/llvm_mir_flang/bin/flang+0x71a1ab0)
#22 0x000055f5b5152c09 mlir::PassManager::run(mlir::Operation*) (/home/shivaram/llvm_mir_flang/bin/flang+0x71a2c09)
#23 0x000055f5afa59c86 Fortran::frontend::CodeGenAction::generateLLVMIR() (/home/shivaram/llvm_mir_flang/bin/flang+0x1aa9c86)
#24 0x000055f5afa5e898 Fortran::frontend::CodeGenAction::executeAction() (/home/shivaram/llvm_mir_flang/bin/flang+0x1aae898)
#25 0x000055f5af772da0 Fortran::frontend::FrontendAction::execute() (/home/shivaram/llvm_mir_flang/bin/flang+0x17c2da0)
#26 0x000055f5af7600ab Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/home/shivaram/llvm_mir_flang/bin/flang+0x17b00ab)
#27 0x000055f5af77e5c9 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/home/shivaram/llvm_mir_flang/bin/flang+0x17ce5c9)
#28 0x000055f5af128a3f fc1_main(llvm::ArrayRef<char const*>, char const*) (/home/shivaram/llvm_mir_flang/bin/flang+0x1178a3f)
#29 0x000055f5af033f9a main (/home/shivaram/llvm_mir_flang/bin/flang+0x1083f9a)
#30 0x00007f639a42fd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007f639a42fe40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007f639a42fe40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x000055f5af1275b5 _start (/home/shivaram/llvm_mir_flang/bin/flang+0x11775b5)
flang-21: error: unable to execute command: Aborted (core dumped)
flang-21: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 21.0.0git (https://github.com/llvm/llvm-project.git b12d68e0b253b4dc6c3fd9d99ee8421605e274aa)
Target: x86_64-unknown-linux-gnu ```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to