Issue 166687
Summary Assertion failed: 'Cache.back() == Reg' in llvm::MCRegAliasIterator when running MLIR lowering pipeline (mlir-runner crash on X86 backend)
Labels mlir
Assignees
Reporter Subway2023
    # Description
When running an MLIR program through the standard lowering pipeline to LLVM and executing it with mlir-runner, LLVM crashes with an assertion failure inside the X86 backend (MCRegAliasIterator).

This appears to be a backend-level issue during the X86 DAG->DAG Instruction Selection phase, likely triggered by an invalid or corrupted register alias table entry.

# Reproduction steps
mlir input: [test.txt](https://github.com/user-attachments/files/23380297/test.txt)
mlir-opt version: LLVM version 21.1.2
mlir-runner version: LLVM version 21.1.2

Commands used
```
/llvm-project-llvmorg-21.1.2/build/bin/mlir-opt \
  --arith-expand \
  --arith-unsigned-when-equivalent \
  --canonicalize \
  --lower-affine \
  --finalize-memref-to-llvm \
  --convert-vector-to-scf \
  --convert-vector-to-llvm \
  --convert-arith-to-llvm \
  --convert-scf-to-cf \
  --convert-arith-to-llvm \
  --convert-func-to-llvm \
  -convert-to-llvm \
  --reconcile-unrealized-casts \
  test.mlir \
  | /llvm-project-llvmorg-21.1.2/build/bin/mlir-runner \
    -e func1 \
    --entry-point-result=void \
    --shared-libs=/llvm-project-llvmorg-21.1.2/build/lib/libmlir_runner_utils.so,/llvm-project-llvmorg-21.1.2/build/lib/libmlir_c_runner_utils.so
```

Sometimes, it executes successfully.
```
( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 )
( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 )
·······
1
0
```

Sometimes, it crashes during execution.
```
·····
mlir-runner: /mnt/sdd1/sbw/mlir/tool/llvm-project-llvmorg-21.1.2/llvm/include/llvm/MC/MCRegisterInfo.h:757: llvm::MCRegAliasIterator::MCRegAliasIterator(llvm::MCRegister, const llvm::MCRegisterInfo*, bool): Assertion `Cache.back() == Reg' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /mnt/sdd1/sbw/mlir/tool/llvm-project-llvmorg-21.1.2/build/bin/mlir-runner -e func1 --entry-point-result=void --shared-libs=/mnt/sdd1/sbw/mlir/tool/llvm-project-llvmorg-21.1.2/build/lib/libmlir_runner_utils.so,/mnt/sdd1/sbw/mlir/tool/llvm-project-llvmorg-21.1.2/build/lib/libmlir_c_runner_utils.so
1.      Running pass 'Function Pass Manager' on module '__standard_lib'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@__lljit_run_atexits'
 #0 0x00005c6934ffeb52 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/sdd1/sbw/mlir/tool/llvm-project-llvmorg-21.1.2/build/bin/mlir-runner+0x599b52)
·····
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to