<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122695>122695</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] remove-dead-values pass removes value that should be live
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
azecevicTT
</td>
</tr>
</table>
<pre>
Here is an example IR:
```mlir
module {
func.func public @main(%arg0: f32) -> f32 {
%0 = call @f(%arg0) : (f32) -> f32
return %0 : f32
}
func.func private @f(%arg0: f32) -> f32 {
%0 = arith.addf %arg0, %arg0 : f32
return %0 : f32
}
}
```
Running `mlir-opt -remove-dead-values` on it gives an error:
```
bug.mlir:9:5: error: null operand found
return %0 : f32
^
bug.mlir:9:5: note: see current operation: "func.return"(<<NULL VALUE>>) : (<<NULL TYPE>>) -> ()
```
Changing the order of the `@main` and `@f` produces a valid result.
Git version: https://github.com/llvm/llvm-project/commit/2914ba1c01fdc496082197abf7cd35e2af526634
System: `Ubuntu 22.04`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVNuK5DYQ_Rr5pWgjS760H_zgnZlOAkMIm5lAHmWpbCvIUqOLyebrg-3u3ckOQxIQutfRqXNEiRD0ZBE7Un0i1WMmUpyd78RfKHHV8uUlG5z60v2IHkEHEBbwT7FcDcJPnwnvCd1bTY-2GO0J7RenkkEgzSdCe4AxWZlvHVzTYLQEUtJFaEvYmbBK-IkS3sPIGWEtnAh_2uZfowEIqygQ_ghSGLMFj28iWQtbNGHn7wBuwR5j8vaO0d9PSPN4cP8HPa9XEfH7J_4bOeF1nHOh1AhfuT3cp2-f_pjUndXR30U9eH5O1mo7wU3lk7tGOHlc3IonhUKdVmESBlJTcBZ0hEmveBjmvfPvvSK0H9KU75bxviW8rzYq99tgkzHgruiFVTC6ZNW_kAcg1dMHqNZF3MaACDJ5jzYe2FE7e_jHdh8OcMLYpj9_IPzh59fnZ_itf359Inxv3xx_c-Hl91_enO8-7Q6275V8mIWdNinjjOC8Qg9u3BfbldvXrClseR8747a8eqeS3CSFVRitwGNIJuYH6A86woo-3NKZY7yGTXN2Iewy6TinIZduIexizHofTlfv_kAZCbtItyx6m7C2KAdRSFqMSpZtTc-saBsxjI1UvEImxorVNS8J7X_9EiIuuxY1fR2SjQkYy2lJapqpjquWtyLDrmh43dTnmtfZ3FEuy0LUZ8FrSRtKKfKyOY_NeRTyXA1jpjtGWUWLghdFyas6R6lqTou2LYqhZLIiJcVFaJNvKeTOT5kOIWFXMFa3VWbEgCbs9YSx_R8wtlUW3-0pD2kKpKRGhxi-IUQdzV6D9oDqEd7_bLiKEG77AfY9iLOIEGaXjIIBwegVs-RN97_l3zMIhF1uSawd-zsAAP___iR3AQ">