[PATCH] MachineVerifier
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 03:22:26 PDT 2015
Hi,
MachineVerifier asserted on SystemZ/xor-01.ll, while analyzing a frame
index, saying
*** Bad machine code: Instruction loads from dead spill slot ***
This was a mem-to-mem instruction which was in fact storing to the spill
slot, so the code was correct.
To help verifier with this, one option might be to analyze the
memoperands of the MI and see
if the FI is used for storing or loading. I however simplified this a
bit, and in this case only checked
for liveness at the reg-slot index of MI. Memoperands are only checked
loosely in the verifier, so I hesitated
on verifying the liveness based on them.
So, with this patch, a mem-to-mem move that loads / stores using a frame
index gets a check that the spill slot is live.
For the case where this MI loads from the FI, we don't check that the
early-clobber index is live, which it should be
for a simple load.
Can I commit this?
/Jonas Paulsson
Patch:
Let MachineVerifier be aware of mem-to-mem instructions.
A mem-to-mem instruction (that both loads and stores), which store
to an
FI, cannot pass the verifier if it thinks it is loading from the FI.
In this case, do a looser check in visitMachineOperand() and only check
liveness at the reg-slot while analyzing a frame index operand.
(Needed to make SystemZ/xor-01.ll pass with -verify-machineinstrs).
diff --git a/lib/CodeGen/MachineVerifier.cpp
b/lib/CodeGen/MachineVerifier.cpp
index 2faee5f..90d87e5 100644
--- a/lib/CodeGen/MachineVerifier.cpp
+++ b/lib/CodeGen/MachineVerifier.cpp
@@ -989,7 +989,12 @@ MachineVerifier::visitMachineOperand(const
MachineOperand *MO, unsigned MONum) {
LiveInts && !LiveInts->isNotInMIMap(MI)) {
LiveInterval &LI = LiveStks->getInterval(MO->getIndex());
SlotIndex Idx = LiveInts->getInstructionIndex(MI);
- if (MI->mayLoad() && !LI.liveAt(Idx.getRegSlot(true))) {
+
+ // For a memory-to-memory move, we don't know if MI is using
+ // this frame index for loading or storing, so check for
+ // liveness at reg-slot only in this case.
+ bool simpleLoad = (MI->mayLoad() && !MI->mayStore());
+ if (simpleLoad && !LI.liveAt(Idx.getRegSlot(true))) {
report("Instruction loads from dead spill slot", MO, MONum);
errs() << "Live stack: " << LI << '\n';
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Let-MachineVerifier-be-aware-of-mem-to-mem-instructi.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151009/bce3ae19/attachment.bin>
More information about the llvm-commits
mailing list