<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64089>64089</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] TestConstantFold crashed with segmentation fault
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Colloportus0
</td>
</tr>
</table>
<pre>
MLIR built at commit 585cbe3f
Reproduced with:
`mlir-opt --test-constant-fold temp.mlir`
temp.mlir:
``` milr
module {
func.func @func1() {
%cst_17 = arith.constant 1.542000e+03 : f16
%true_22 = arith.constant true
%c1_24 = arith.constant 1 : index
%c11_28 = arith.constant 11 : index
%13 = tensor.empty() : tensor<24x24xf32>
%cst_54 = arith.constant dense<1.41865946E+9> : vector<24x24xf32>
%23 = vector.fma %cst_54, %cst_54, %cst_54 : vector<24x24xf32>
%cst_63 = arith.constant dense<true> : vector<24x24xi1>
%cst_64 = arith.constant dense<117562519> : vector<24x24xi32>
%42 = vector.gather %13[%c11_28, %c1_24] [%cst_64], %cst_63, %23 : tensor<24x24xf32>, vector<24x24xi32>, vector<24x24xi1>, vector<24x24xf32> into vector<24x24xf32>
%53 = scf.if %true_22 -> (f16) {
scf.yield %cst_17 : f16
} else {
%117 = vector.mask %cst_63 { vector.multi_reduction <maxf>, %cst_54, %42 [] : vector<24x24xf32> to vector<24x24xf32> } : vector<24x24xi1> -> vector<24x24xf32>
%119 = math.round %13 : tensor<24x24xf32>
scf.yield %cst_17 : f16
}
%alloc_70 = memref.alloc() : memref<1xi32>
return
}
}
```
trace:
```console
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: mlir-opt --test-constant-fold temp.mlir
#0 0x000000010047ca90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f8a90)
#1 0x000000010047ad2c llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f6d2c)
#2 0x000000010047d13c SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f913c)
#3 0x00000001be7894c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
#4 0x0000000102c27de0 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/workspace/build/bin/mlir-opt+0x102aa3de0)
#5 0x0000000102c27de0 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/workspace/build/bin/mlir-opt+0x102aa3de0)
#6 0x0000000102b253cc mlir::OperationFolder::tryToFold(mlir::Operation*, bool*) (/workspace/build/bin/mlir-opt+0x1029a13cc)
#7 0x0000000102a75b40 (anonymous namespace)::TestConstantFold::runOnOperation() (/workspace/build/bin/mlir-opt+0x1028f1b40)
#8 0x0000000102acbefc mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x102947efc)
#9 0x0000000102acc5ec mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x1029485ec)
#10 0x0000000102ace480 mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x10294a480)
#11 0x0000000102ac6968 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x102942968)
#12 0x0000000102ac5fbc mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_1>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) (/workspace/build/bin/mlir-opt+0x102941fbc)
#13 0x0000000102b43fa0 mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/workspace/build/bin/mlir-opt+0x1029bffa0)
#14 0x0000000102ac0970 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x10293c970)
#15 0x0000000102ac0de0 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x10293cde0)
#16 0x0000000100187088 main (/workspace/build/bin/mlir-opt+0x100003088)
#17 0x000000010bbe5088
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWV1v4ywW_jXkBjXCYDv2RS7StNGONNVU7WhvI4xxwg4GL-B3mn-_AjuNHSedabTaj6mqxDaHw3Oe8wUOtVbsFOdLkNyD5GFGW7fXZrnWUupGG9daNCt0eVg-ff3yAotWSAepg0zXtXAQJlnCCk4qgB4AWr3wxuiyZbyEP4XbA7KCsBsBKaqlMHe6cfDuznHr7phW1lHl7iotS-h43cy9CEhRPyV8np6T1buq7h_WQppef63LVnIIFvfdPYRVq9jcf0AQI_8dAZwBnA9lIAQ4YdZtowUE5AFSI9x-fgQGo3kSY4QQB_geEejNqaJ0NNmZlm8xvjTbD40XirY4vrhOUC1Uyd_OJkRbnF2cMZ0CcBKRIOu4strMed24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