<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63399>63399</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] [hlfir] crash with "failed to materialize conversion for result #0 of operation 'hlfir.transpose' that remained live after conversion"
</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>
Test program:
https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/transpose_1.f90
Step to reproduce:
```console
flang-new -c -O1 -flang-experimental-hlfir transpose_1.f90
```
Error messages before crash:
```console
error: loc("./transpose_1.f90":21:5): failed to materialize conversion for result #0 of operation 'hlfir.transpose' that remained live after conversion
error: loc("./transpose_1.f90":20:3): failure in HLFIR intrinsic simplification
error: loc("./transpose_1.f90":24:5): failed to materialize conversion for result #0 of operation 'hlfir.transpose' that remained live after conversion
error: loc("./transpose_1.f90":23:3): failure in HLFIR intrinsic simplification
error: Lowering to LLVM IR failed
error: loc("./transpose_1.f90":8:3): cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
error: failed to create the LLVM module
```
Stack dump:
```console
#0 0x000055d251826584 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
#1 0x000055d251826bd4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007ff1def43520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000055d251970e20 Fortran::frontend::CodeGenAction::executeAction()
#4 0x000055d251846fde Fortran::frontend::FrontendAction::execute()
#5 0x000055d25183f1f7 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&)
#6 0x000055d2518497b6 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*)
#7 0x000055d2508c1824 fc1_main(llvm::ArrayRef<char const*>, char const*)
#8 0x000055d2508bf9d2 main
#9 0x00007ff1def2ad90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#10 0x00007ff1def2ae40 call_init ./csu/../csu/libc-start.c:128:20
#11 0x00007ff1def2ae40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#12 0x000055d2508bee35 _start
flang-new: error: unable to execute command: Segmentation fault
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 64083172eea26e50c8b22b85697a825be8bda424)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```
Another reproducer:
https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/transpose_intrinsic_func_call_1.f90
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV91u27gSfhr6hrBAjf4vfOE29WmAHJyDJthbg6JGMrc0KZBUfvbpF6Rsx3aDtAEWKBZIZHJEfvPNcDgz4s7JQSOuSPGJFDcLPvmdsavvS26teXKL1nQvqwd0no7WDJbvSbYm7Iaw9c770YUZbAhsBul3U5sIsyewUerx-LP06PzSTdIjgU2rTEtgs-dSE9hsjPWWh9HQn4YWB4vOSRMmQeZG43CbJn3DZsXz897jSL2hFkdrukngiRgp2fwnjHZG4SztFdfDUuMTXQq6_F9Kl7MEn0e0co_ac7XcqV5a-rbWI-o5iS_WGkv36Bwf0NEWe2ORCsvd7id0MOwk2ZoqIwjUBCB5w14Akq0hJdm6INCE5T2XCrtg-J57tJIr-RdSYfQj2uA02htLLbpJeUogY9T01IxouQ8vCVTRxOSkiEBF_Y57ajGcCnZUyUekvPdoz2A_TpqRbJ2dkZ4sUqnp17vN7TcqtbdSOymok_tRyV6KSPDjavJ_o2-yf8A3d-YJrdRDMPfu7o__0ttvBwd8mE99RkdwrY2n7dFvfnboQUNYsZfOBb2kZEH6EBBVZHgjuULhb7VH23OBpGTU4iCdP7g4-L-bF8WxGaMHJi2S8Lgi_nqcwiL3SP0OZyJ7003Hi_Tmvbz3XHyn3bQff3IN5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