<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118448>118448</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] -int-range-optimizations crashes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wwy6191
</td>
</tr>
</table>
<pre>
git version: d09707070c7460d0887eae8f7022e816510d5eb1
system: `Ubuntu 18.04.6 LTS`
reproduce with: `mlir-opt -int-range-optimizations a.mlir`
a.mlir:
```
module {
func.func @f(%arg0: f32) {
%c0 = arith.constant 0 : index
return
^BB1(%0: i32): // no predecessors
%cst = arith.constant 1.000000e+00 : f32
%c0_0 = arith.constant 0 : index
%c10 = arith.constant 10 : index
%c1 = arith.constant 1 : index
%alloc = memref.alloc() : memref<10xf32>
%c0_1 = arith.constant 0 : index
%c10_2 = arith.constant 10 : index
%c1_3 = arith.constant 1 : index
cf.br ^BB2(%c0_1 : index)
^BB2(%1: index): // 2 preds: ^BB1, ^BB3
%2 = arith.cmpi slt, %1, %c10 : index
cf.cond_br %2, ^BB3(%1 : index), ^BB4
^BB3(%3: index): // 2 preds: ^BB2, ^BB5
%4 = arith.cmpi slt, %3, %c10 : index
cf.cond_br %4, ^BB4, ^BB6
^BB4: // pred: ^BB3
%5 = memref.load %alloc[%1] : memref<10xf32>
%6 = arith.addf %5, %cst : f32
memref.store %6, %alloc[%1] : memref<10xf32>
%7 = arith.addi %3, %c1 : index
cf.br ^BB5(%7 : index)
^BB5(%8: index): // 2 preds: ^BB4, ^BB5
%9 = arith.cmpi slt, %8, %c10 : index
cf.cond_br %9, ^BB6, ^BB7
^BB6: // pred: ^BB5
%10 = arith.addi %8, %c1 : index
cf.br ^BB5(%10 : index)
^BB7: // pred: ^BB6
return
}
}
```
stack trace:
```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/llvm/include/llvm/ADT/APInt.h:1044: bool llvm::APInt::operator[](unsigned int) const: Assertion `bitPosition < getBitWidth() && "Bit position out of bounds!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -int-range-optimizations /data/szy/MLIR/seed/seed15/tmp.PBBqjgej6E.mlir
#0 0x0000564c888a3f88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1185f88)
#1 0x0000564c888a1a9e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1183a9e)
#2 0x0000564c888a491d SignalHandler(int) Signals.cpp:0:0
#3 0x00007f16eb052420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f16ea68f00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f16ea66e859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007f16ea66e729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007f16ea66e729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007f16ea67ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x0000564c8e906c96 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x71e8c96)
#10 0x0000564c8de24c0f mlir::intrange::inferMinS(llvm::ArrayRef<mlir::ConstantIntRanges>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x6706c0f)
#11 0x0000564c88b9c7b8 mlir::arith::MinSIOp::inferResultRanges(llvm::ArrayRef<mlir::ConstantIntRanges>, llvm::function_ref<void (mlir::Value, mlir::ConstantIntRanges const&)>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x147e7b8)
#12 0x0000564c88b6dd91 mlir::detail::InferIntRangeInterfaceInterfaceTraits::Model<mlir::arith::MinSIOp>::inferResultRanges(mlir::detail::InferIntRangeInterfaceInterfaceTraits::Concept const*, mlir::Operation*, llvm::ArrayRef<mlir::ConstantIntRanges>, llvm::function_ref<void (mlir::Value, mlir::ConstantIntRanges const&)>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x144fd91)
#13 0x0000564c8e9076e6 mlir::intrange::detail::defaultInferResultRanges(mlir::InferIntRangeInterface, llvm::ArrayRef<mlir::IntegerValueRange>, llvm::function_ref<void (mlir::Value, mlir::IntegerValueRange const&)>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x71e96e6)
#14 0x0000564c8bcc7b6c mlir::dataflow::IntegerRangeAnalysis::visitOperation(mlir::Operation*, llvm::ArrayRef<mlir::dataflow::IntegerValueRangeLattice const*>, llvm::ArrayRef<mlir::dataflow::IntegerValueRangeLattice*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45a9b6c)
#15 0x0000564c8bccc4f9 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::visitOperation(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45ae4f9)
#16 0x0000564c8bccbb99 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45adb99)
#17 0x0000564c8bccbe4d mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45ade4d)
#18 0x0000564c8bccbe4d mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45ade4d)
#19 0x0000564c8bc9bc8e mlir::DataFlowSolver::initializeAndRun(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x457dc8e)
#20 0x0000564c88bd707d (anonymous namespace)::IntRangeOptimizationsPass::runOnOperation() IntRangeOptimizations.cpp:0:0
#21 0x0000564c8bcde936 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45c0936)
#22 0x0000564c8bcdf260 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45c1260)
#23 0x0000564c8bce1832 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45c3832)
#24 0x0000564c8bcda0da performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x0000564c8bcd9d2d llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#26 0x0000564c8bd85fa5 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4667fa5)
#27 0x0000564c8bcd3d15 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45b5d15)
#28 0x0000564c8bcd3fbf mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45b5fbf)
#29 0x0000564c8bcd42ee mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45b62ee)
#30 0x0000564c88884a77 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1166a77)
#31 0x00007f16ea670083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#32 0x0000564c888845ee _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11665ee)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWllz2zgS_jX0C8oqELwf_CBfta6Kyy47u_uoAoGmjBkK4ACgj_n1WwAp8YjkOJkoqZ3JeCQeje7v6240GqSoMWItAc6C5DxILk9oa5-UPnt5eUvDIjwpFX87WwuLnkEboWQQLRHHRYbdfyyLU8xxnmdAIa8yTAjkYZqEmCdQhgFeBnhp3oyFjRsXpPjfZStti8J8geNFij59fgxS3MlpaLTiLQP0IuxTL7-phT5VjUXoVEh7qqlcgzsXG_EntUJJg-jCCe3UBHjZX4mWCLkLKe7-3MlG8bYGFGTnAV4iVLWSLdwHCmJcBSQPSEL1GruxVUQCUuxEEQpIwjAKoktEtbBPC6aksVR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