Skip to content

Commit

Permalink
[RegisterScavenging] Add asserts for better errors
Browse files Browse the repository at this point in the history
These cases were failing before, but with cryptic asserts.
Add asserts in the RegScavenger that fail earlier with better
messages. NFC

Differential Revision: https://reviews.llvm.org/D100109
  • Loading branch information
Flakebi committed Apr 9, 2021
1 parent 36138db commit ba217b4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions llvm/lib/CodeGen/RegisterScavenging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ findSurvivorBackwards(const MachineRegisterInfo &MRI,
const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
LiveRegUnits Used(TRI);

assert(From->getParent() == To->getParent() &&
"Target instruction is in other than current basic block, use "
"enterBasicBlockEnd first");

for (MachineBasicBlock::iterator I = From;; --I) {
const MachineInstr &MI = *I;

Expand Down Expand Up @@ -423,6 +427,8 @@ findSurvivorBackwards(const MachineRegisterInfo &MRI,
if (I == MBB.begin())
break;
}
assert(I != MBB.begin() && "Did not find target instruction while "
"iterating backwards");
}

return std::make_pair(Survivor, Pos);
Expand Down

0 comments on commit ba217b4

Please sign in to comment.