The content of undef registers are not used in meaningful ways, when checking
if a rename register is used between paired instructions we should ignore
undef registers.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Take test mir attached test/CodeGen/AArch64/stp-opt-with-renaming-crash.mir
run with llc -run-pass=aarch64-ldst-opt -mtriple=aarch64 -verify-machineinstrs
Then you will see assertion
"Rename register used between paired instruction, trashing the content".
Although we don't really care trashing content of an undef, but should we exclude undef when checking for overlap ?
#if !defined(NDEBUG) // Make sure the register used for renaming is not used between the paired // instructions. That would trash the content before the new paired // instruction. for (auto &MI : iterator_range<MachineInstrBundleIterator<llvm::MachineInstr>>( std::next(I), std::next(Paired))) assert(all_of(MI.operands(), [this, &RenameReg](const MachineOperand &MOP) { return !MOP.isReg() || MOP.isDebug() || !MOP.getReg() || **MOP.isUndef() ||** !TRI->regsOverlap(MOP.getReg(), *RenameReg); }) && "Rename register used between paired instruction, trashing the " "content"); #endif
Probably the code printing the "Rename register used between paired instruction" diagnostic should ignore undef use; such uses don't use the value in any meaningful way.
For reference, the code in LiveRegUnits considers isDef() a write, and readsReg() a read.
Thanks for fixing that!
llvm/test/CodeGen/AArch64/stp-opt-with-renaming-undef-assert.mir | ||
---|---|---|
40 ↗ | (On Diff #407598) | Are those needed or could be dropped? |
Thanks @fhahn , stack accesses are not needed. I just clean them in https://reviews.llvm.org/rG19302cd7a449