llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Flang][HLFIR] Assertion `sliceFields.empty() && substring.empty()' failed.

Open k-arrows opened this issue 2 years ago • 3 comments

Reproducer:

program test
    implicit none

    class(*),pointer :: p(:)
    character(len=2),target:: c(2)=['ab','cd']

    p=>c

    select type(p)
       type is(character(*))
          associate(x=>p(1:2))
          end associate
       class default
         error stop 1
    end select

end

Assertion failure:

flang-new: /path_to_llvm_project/llvm-project/flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp:583: virtual mlir::LogicalResult (anonymous namespace)::DesignateOpConversion::matchAndRewrite(hlfir::DesignateOp, mlir::PatternRewriter &) const: Assertion `sliceFields.empty() && substring.empty()' failed.

Stack dump:

 #0 0x0000562f1ed7d27f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
 #1 0x0000562f1ed7d8b3 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fa7c2481520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007fa7c24d5a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #4 0x00007fa7c24d5a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #5 0x00007fa7c24d5a7c pthread_kill ./nptl/pthread_kill.c:89:10
 #6 0x00007fa7c2481476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007fa7c24677f3 abort ./stdlib/abort.c:81:7
 #8 0x00007fa7c246771b _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007fa7c2478e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x0000562f1fd82757 (anonymous namespace)::DesignateOpConversion::matchAndRewrite(hlfir::DesignateOp, mlir::PatternRewriter&) const ConvertToFIR.cpp:0:0
#11 0x0000562f20513391 void llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_2>(long) PatternApplicator.cpp:0:0
#12 0x0000562f20510e33 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)
#13 0x0000562f204e6918 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#14 0x0000562f204e60c2 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*)
#15 0x0000562f204e6d3e mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>)
#16 0x0000562f204eb132 mlir::applyPartialConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig)
#17 0x0000562f204eb8a1 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) 
#18 0x0000562f1fd7ec38 (anonymous namespace)::ConvertHLFIRtoFIR::runOnOperation() ConvertToFIR.cpp:0:0
#19 0x0000562f21ab1584 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7>(long) Pass.cpp:0:0
#20 0x0000562f21aada67 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)
#21 0x0000562f21aade6f mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*)
#22 0x0000562f21aaf777 mlir::PassManager::run(mlir::Operation*)
#23 0x0000562f1f1ac058 Fortran::frontend::CodeGenAction::generateLLVMIR()
#24 0x0000562f1f1ad727 Fortran::frontend::CodeGenAction::executeAction()
#25 0x0000562f1eda18bc Fortran::frontend::FrontendAction::execute()
#26 0x0000562f1ed96264 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&)
#27 0x0000562f1eda46c6 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*)
#28 0x0000562f1ea484d5 fc1_main(llvm::ArrayRef<char const*>, char const*)
#29 0x0000562f1ea474a6 main
#30 0x00007fa7c2468d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007fa7c2468e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007fa7c2468e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x0000562f1ea46a05 _start
flang-new: error: unable to execute command: Aborted
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 330af6ed6194ca5365bc576517c247f545aee1f4)
Target: x86_64-unknown-linux-gnu
Thread model: posix

k-arrows avatar Feb 24 '24 15:02 k-arrows

The same or similar assertion failure has been reported recently. See https://github.com/llvm/llvm-project/issues/94386.

k-arrows avatar Jun 04 '24 23:06 k-arrows

@k-arrows This issue seems fixed.

DanielCChen avatar Nov 03 '25 19:11 DanielCChen

@k-arrows This issue seems fixed.

Thank you. I will close this issue.

k-arrows avatar Nov 03 '25 23:11 k-arrows