<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63623>63623</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] flang-new crashes (gfortran/regression/dtio_3.f90)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Crashed by the following test program:
https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/dtio_3.f90
Step to reproduce:
```shell
flang-new -flang-experimental-polymorphism dtio_3.f90
```
Error message before crash:
```console
error: loc("./dtio_3.f90":91:90): 'llvm.call' op incorrect number of operands (2) for callee (expecting: 3)
error: Lowering to LLVM IR failed
```
Assertion(llvm/lib/IR/Instructions.cpp:649):
```console
void llvm::CallInst::init(llvm::FunctionType *, llvm::Value *, ArrayRef<llvm::Value *>, ArrayRef<llvm::OperandBundleDef>, const llvm::Twine &): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"' failed.
```
Stack dump:
```console
#0 0x00005612df255972 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
#1 0x00005612df255fc2 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f4396403520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007f4396457a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#4 0x00007f4396457a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#5 0x00007f4396457a7c pthread_kill ./nptl/pthread_kill.c:89:10
#6 0x00007f4396403476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007f43963e97f3 abort ./stdlib/abort.c:81:7
#8 0x00007f43963e971b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#9 0x00007f43963fae96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x00005612e1c21878 llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::Twine const&)
#11 0x00005612de301130 llvm::CallInst::Create(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*>>, llvm::Twine const&, llvm::Instruction*)
#12 0x00005612de3007f2 llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::MDNode*)
#13 0x00005612e0546398 convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) LLVMToLLVMIRTranslation.cpp:0:0
#14 0x00005612e0ce149e mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&)
#15 0x00005612e0ce178a mlir::LLVM::ModuleTranslation::convertBlock(mlir::Block&, bool, llvm::IRBuilderBase&)
#16 0x00005612e0ce29de mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp)
#17 0x00005612e0ce3b2c mlir::LLVM::ModuleTranslation::convertFunctions()
#18 0x00005612e0ce53a0 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef)
#19 0x00005612df3a18fe Fortran::frontend::CodeGenAction::generateLLVMIR()
#20 0x00005612df3a2d76 Fortran::frontend::CodeGenAction::executeAction()
#21 0x00005612df276d0e Fortran::frontend::FrontendAction::execute()
#22 0x00005612df26ef07 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&)
#23 0x00005612df2794e6 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*)
#24 0x00005612de2cb984 fc1_main(llvm::ArrayRef<char const*>, char const*)
#25 0x00005612de2c9b32 main
#26 0x00007f43963ead90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#27 0x00007f43963eae40 call_init ./csu/../csu/libc-start.c:128:20
#28 0x00007f43963eae40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#29 0x00005612de2c8f95 _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 17.0.0 (https://github.com/llvm/llvm-project.git cc31d787c3f29f3afbbfee15e1dda846ec962d70)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WFtvoz4W_zTOi5UIbK4PeUjTyW6l-V_UqeY1MnAg3hqMbNPLfvqVDSRA006nK_2lTgZ8-Z3fuXB8jpnWvGoAtii8QeHtinXmJNX2cc2Uks96lcnidbtXTJ-gwNkrNifApRRCPvOmwga0wa2SlWI1ojvk3SJvdzKm1faNHBA5VNycumyTyxqRgxBP439ru3etO24AkUMmZIbIoWa8QeRwkMooZp-q8vyooFKgNZf2pTBcHummTL1eZv_7w0CLjcQKWiWLLoczJxR5_Z8-gRD9WClYU60beMbr_hFeWlC8hsYwsW6leK2lak9c1_iNuBFuKv2bUlLhGrRmFeAMSqkA59Z0b2nkstFSQD8KdiOiOyxkjkiCCNnMVSQE0V3q2x8PkdQuRSS2VtzkTAhEYixbzJtcKgW5wU1XZ6CwLLFsQbGm0BiRhCCS4lIqbPcA2CGrcW54U1lIaqHnhL7LZ1DO0RJ___7zD3x3j0vGBRQf2GGnNSjj_JSMDufWu3f39qfRRnW5ndebvG0R3UVB2mv1kZGeJC-wg6M7RHd7JoSF6t94w80ozQ0cusaJeHhtraI7RPaTzT-Z6M7DO6XY6z2UiO6vraDf3l30V2_cm64pBNzaSbfW0jYTaQ_PvLFY0eC6s32wVZMkO1Xpjeb_Bef7FCN6i-gtPjy8rhH9VoH5s6v_ZorVelwQ71G8t_4b1nD9k6mdqsZ5KyrCb3G_vQ_a_41bESHWwNbzDJeDLfEzNyecsQLblMFMpwAR3wYniYeo2HwQFj8Myx9x0dXtLzyNEaEe9l48z_PCyCdFScIwjcnEpPpV9w9_K94Yh_ygWA6zGFD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