llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.38k stars 11.73k forks source link

[RISCV] Post-PEI MIR testing is broken with Zcmp/libcalls #79491

Closed francisvm closed 8 months ago

francisvm commented 8 months ago

MIR printing is broken when trying to serialize the output after PrologEpilogInserter (-run-pass=prologepilog or -stop-after).

llc -mtriple=riscv32 -mattr=+zcmp -x mir -run-pass=prologepilog -verify-machineinstrs -o -zcmp-cm-push-pop.mir:

Assertion failed: (unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && "Invalid Object Idx!"), function isDeadObjectIndex, file MachineFrameInfo.h, line 747.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

Zcmp/save-restore-libcalls have pre-defined frame indices for the saved registers but they're never allocated in MachineFrameInfo. When MIRPrinting occurs, the index found in the entries in MachineFrameInfo::CalleeSavedInfos is not to be found in MachineFrameInfo::Objects, and isDeadObjectIndex asserts.

We should create proper (fixed?) slots in MFI in the future to avoid inconsistencies there, since we don't really care about the frame index to be fixed, but the location on the stack.

llvmbot commented 8 months ago

@llvm/issue-subscribers-backend-risc-v

Author: Visoiu Mistrih Francis (francisvm)

MIR printing is broken when trying to serialize the output after PrologEpilogInserter (`-run-pass=prologepilog` or `-stop-after`). `llc -mtriple=riscv32 -mattr=+zcmp -x mir -run-pass=prologepilog -verify-machineinstrs -o - `[zcmp-cm-push-pop.mir](https://github.com/llvm/llvm-project/files/14056737/zcmp-cm-push-pop.mir.txt): ``` Assertion failed: (unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && "Invalid Object Idx!"), function isDeadObjectIndex, file MachineFrameInfo.h, line 747. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. ``` Zcmp/save-restore-libcalls have pre-defined frame indices for the saved registers but they're never allocated in `MachineFrameInfo`. When MIRPrinting occurs, the index found in the entries in `MachineFrameInfo::CalleeSavedInfos` is not to be found in `MachineFrameInfo::Objects`, and `isDeadObjectIndex` asserts. We should create proper (fixed?) slots in MFI in the future to avoid inconsistencies there, since we don't really care about the frame index to be fixed, but the location on the stack.
asb commented 8 months ago

Did #79535 fix this, or are there still other related issues?

francisvm commented 8 months ago

Should be good for now! Probably still good to create proper slots in MFI later, but at least MIR testing works.