Issue 94144
Summary [Flang] flang-new crashes with "nonscalar intrinsic argument" on MERGE(TSOURCE, FSOURCE, MASK)
Labels flang
Assignees
Reporter k-arrows
    Reproducible on Godbolt:
https://godbolt.org/z/zanTG7xvo

Reproducer (reduced and modified from https://github.com/rzurob/llvm-test-suite/blob/ibm_fortran_tests/Fortran/IBM/execute/F2003/OO_poly/intrinsics/merge/argAssociation003.f03):
```console
subroutine s(arg1, arg2)
  class(*) :: arg1(2), arg2(:)
  logical :: m1(2)
  m1 = (/.TRUE.,.FALSE./)

  res = merge(arg1, arg2, m1)

end
```

Stack dump:
```console
error: loc("/app/example.f90":6:3): nonscalar intrinsic argument
LLVM ERROR: aborting
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/.. -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #0 0x0000000003855538 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x3855538)
 #1 0x0000000003852eac SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fe00ea42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007fe00ea969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007fe00ea42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007fe00ea287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000001e8ad24 llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
 #7 0x00000000037af138 (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x37af138)
 #8 0x0000000003c292e3 (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x3c292e3)
 #9 0x0000000004f27e0f fir::ExtendedValue fir::IntrinsicLibrary::genElementalCall<fir::ExtendedValue (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>)>(fir::ExtendedValue (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>), llvm::StringRef, mlir::Type, llvm::ArrayRef<fir::ExtendedValue>, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x4f27e0f)
#10 0x0000000004f2811c std::__detail::__variant::__gen_vtable_impl<true, std::__detail::__variant::_Multi_array<fir::ExtendedValue (*)(fir::IntrinsicLibrary::genIntrinsicCall(llvm::StringRef, std::optional<mlir::Type>, llvm::ArrayRef<fir::ExtendedValue>)::'lambda'(auto&)&&, std::variant<mlir::Value (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<mlir::Value>), fir::ExtendedValue (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>), void (fir::IntrinsicLibrary::*)(llvm::ArrayRef<fir::ExtendedValue>), fir::ExtendedValue (fir::IntrinsicLibrary::*)(std::optional<mlir::Type>, llvm::ArrayRef<fir::ExtendedValue>)> const&)>, std::tuple<std::variant<mlir::Value (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<mlir::Value>), fir::ExtendedValue (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>), void (fir::IntrinsicLibrary::*)(llvm::ArrayRef<fir::ExtendedValue>), fir::ExtendedValue (fir::IntrinsicLibrary::*)(std::optional<mlir::Type>, llvm::ArrayRef<fir::ExtendedValue>)> const&>, std::integer_sequence<unsigned long, 1ul>>::__visit_invoke(fir::IntrinsicLibrary::genIntrinsicCall(llvm::StringRef, std::optional<mlir::Type>, llvm::ArrayRef<fir::ExtendedValue>)::'lambda'(auto&)&&, std::variant<mlir::Value (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<mlir::Value>), fir::ExtendedValue (fir::IntrinsicLibrary::*)(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>), void (fir::IntrinsicLibrary::*)(llvm::ArrayRef<fir::ExtendedValue>), fir::ExtendedValue (fir::IntrinsicLibrary::*)(std::optional<mlir::Type>, llvm::ArrayRef<fir::ExtendedValue>)> const&) IntrinsicCall.cpp:0:0
#11 0x0000000004f342c2 fir::IntrinsicLibrary::genIntrinsicCall(llvm::StringRef, std::optional<mlir::Type>, llvm::ArrayRef<fir::ExtendedValue>) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x4f342c2)
#12 0x0000000004f3477f fir::genIntrinsicCall(fir::FirOpBuilder&, mlir::Location, llvm::StringRef, std::optional<mlir::Type>, llvm::ArrayRef<fir::ExtendedValue>, Fortran::lower::AbstractConverter*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x4f3477f)
#13 0x0000000003c8966c genIntrinsicRefCore(llvm::SmallVector<std::optional<Fortran::lower::PreparedActualArgument>, 1u>&, Fortran::evaluate::SpecificIntrinsic const*, fir::IntrinsicArgumentLoweringRules const*, (anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#14 0x0000000003c8aba6 genHLFIRIntrinsicRefCore(llvm::SmallVector<std::optional<Fortran::lower::PreparedActualArgument>, 1u>&, Fortran::evaluate::SpecificIntrinsic const*, fir::IntrinsicArgumentLoweringRules const*, (anonymous namespace)::CallContext&) (.part.0) ConvertCall.cpp:0:0
#15 0x0000000003c8ad67 std::_Function_handler<hlfir::Entity (mlir::Location, fir::FirOpBuilder&, mlir::ValueRange), (anonymous namespace)::ElementalCallBuilder<(anonymous namespace)::ElementalIntrinsicCallBuilder>::genElementalCall(llvm::SmallVector<std::optional<Fortran::lower::PreparedActualArgument>, 1u>&, bool, (anonymous namespace)::CallContext&)::'lambda0'(mlir::Location, fir::FirOpBuilder&, mlir::ValueRange)>::_M_invoke(std::_Any_data const&, mlir::Location&&, fir::FirOpBuilder&, mlir::ValueRange&&) ConvertCall.cpp:0:0
#16 0x0000000004ef3c75 hlfir::genElementalOp(mlir::Location, fir::FirOpBuilder&, mlir::Type, mlir::Value, mlir::ValueRange, std::function<hlfir::Entity (mlir::Location, fir::FirOpBuilder&, mlir::ValueRange)> const&, bool, mlir::Value, mlir::Type) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x4ef3c75)
#17 0x0000000003c8b5e1 (anonymous namespace)::ElementalCallBuilder<(anonymous namespace)::ElementalIntrinsicCallBuilder>::genElementalCall(llvm::SmallVector<std::optional<Fortran::lower::PreparedActualArgument>, 1u>&, bool, (anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#18 0x0000000003c8bf98 genIntrinsicRef(Fortran::evaluate::SpecificIntrinsic const*, (anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#19 0x0000000003c8cef4 genProcedureRef((anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#20 0x0000000003c8f914 Fortran::lower::convertCallToHLFIR(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x3c8f914)
#21 0x0000000003e31fd1 std::__detail::__variant::__gen_vtable_impl<true, std::__detail::__variant::_Multi_array<hlfir::EntityWithAttributes (*)(hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>(Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>> const&)::'lambda'(Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5> const&)&&, std::variant<Fortran::evaluate::Constant<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::ArrayConstructor<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::StructureConstructor, Fortran::evaluate::Designator<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::FunctionRef<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::Parentheses<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>> const&)>, std::tuple<std::variant<Fortran::evaluate::Constant<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::ArrayConstructor<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::StructureConstructor, Fortran::evaluate::Designator<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::FunctionRef<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::Parentheses<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>> const&>, std::integer_sequence<unsigned long, 4ul>>::__visit_invoke(hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>(Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>> const&)::'lambda'(Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5> const&)&&, std::variant<Fortran::evaluate::Constant<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::ArrayConstructor<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::StructureConstructor, Fortran::evaluate::Designator<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::FunctionRef<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>, Fortran::evaluate::Parentheses<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>> const&) ConvertExprToHLFIR.cpp:0:0
#22 0x0000000003e512c8 hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>(Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>> const&) ConvertExprToHLFIR.cpp:0:0
#23 0x0000000003e512ec std::__detail::__variant::__gen_vtable_impl<true, std::__detail::__variant::_Multi_array<hlfir::EntityWithAttributes (*)(hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeType>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&)::'lambda'(Fortran::evaluate::SomeType const&)&&, std::variant<Fortran::evaluate::value::Integer<128, true, 32, unsigned int, unsigned long, 128>, Fortran::evaluate::NullPointer, Fortran::evaluate::ProcedureDesignator, Fortran::evaluate::ProcedureRef, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)0>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)1>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)2>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)3>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)4>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>> const&)>, std::tuple<std::variant<Fortran::evaluate::value::Integer<128, true, 32, unsigned int, unsigned long, 128>, Fortran::evaluate::NullPointer, Fortran::evaluate::ProcedureDesignator, Fortran::evaluate::ProcedureRef, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)0>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)1>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)2>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)3>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)4>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>> const&>, std::integer_sequence<unsigned long, 9ul>>::__visit_invoke(hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeType>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&)::'lambda'(Fortran::evaluate::SomeType const&)&&, std::variant<Fortran::evaluate::value::Integer<128, true, 32, unsigned int, unsigned long, 128>, Fortran::evaluate::NullPointer, Fortran::evaluate::ProcedureDesignator, Fortran::evaluate::ProcedureRef, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)0>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)1>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)2>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)3>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)4>>, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)5>>> const&) ConvertExprToHLFIR.cpp:0:0
#24 0x0000000003e5964b Fortran::lower::convertExprToHLFIR(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x3e5964b)
#25 0x0000000003c4ccec (anonymous namespace)::FirConverter::genDataAssignment(Fortran::evaluate::Assignment const&, Fortran::evaluate::ProcedureRef const*) Bridge.cpp:0:0
#26 0x0000000003c41884 (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&) Bridge.cpp:0:0
#27 0x0000000003c50dfc (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#28 0x0000000003c42aa0 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x3c42aa0)
#29 0x0000000003bd5b3a Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x3bd5b3a)
#30 0x00000000038a5e05 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x38a5e05)
#31 0x0000000003895707 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x3895707)
#32 0x00000000038abe4d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x38abe4d)
#33 0x0000000001fd7188 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x1fd7188)
#34 0x0000000001ec1504 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x1ec1504)
#35 0x00007fe00ea29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007fe00ea29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000001fd60ee _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin/flang-new+0x1fd60ee)
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 f5bab9678e8c6b2a58abc7867a4a64408247cf13)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240601/bin
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to