[PATCH] D19369: VirtRegMap.cpp should not just remove an identity copy which also has a impl-def of a super-reg
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 09:19:35 PDT 2016
jonpa created this revision.
jonpa added a reviewer: qcolombet.
jonpa added a subscriber: llvm-commits.
VirtRegMap removes identity copies, but that leads to machine-verifier complaints if there is a def of a super reg as well.
I am not sure what the best fix is, but the patch attached seems to fix this by transforming the COPY to an IMPLICIT_DEF when there is a def of a super-reg. The patch assumes (arbitrarily) that there could only be one extra operand - not sure if this is always true...
I put this with a testcase on Bugzilla a while ago and would appreciate any review.
https://llvm.org/bugs/show_bug.cgi?id=27156
http://reviews.llvm.org/D19369
Files:
lib/CodeGen/VirtRegMap.cpp
Index: lib/CodeGen/VirtRegMap.cpp
===================================================================
--- lib/CodeGen/VirtRegMap.cpp
+++ lib/CodeGen/VirtRegMap.cpp
@@ -441,10 +441,25 @@
if (MI->isIdentityCopy()) {
++NumIdCopies;
DEBUG(dbgs() << "Deleting identity copy.\n");
- if (Indexes)
- Indexes->removeMachineInstrFromMaps(*MI);
- // It's safe to erase MI because MII has already been incremented.
- MI->eraseFromParent();
+
+ // A COPY which has an implicit def of a super register must
+ // become an IMPLICIT_DEF of that register.
+ if (MI->getNumOperands() > 2) {
+ MachineOperand &MO = MI->getOperand(2);
+ if (MO.isDef() && MO.isImplicit()) {
+ MI->setDesc(TII->get(TargetOpcode::IMPLICIT_DEF));
+ MI->RemoveOperand(0);
+ MI->RemoveOperand(0);
+ MI->getOperand(0).setImplicit(false);
+ assert (MI->getNumOperands() == 1 && "Not a single super reg implicit def?");
+ }
+ }
+ else {
+ if (Indexes)
+ Indexes->removeMachineInstrFromMaps(*MI);
+ // It's safe to erase MI because MII has already been incremented.
+ MI->eraseFromParent();
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19369.54517.patch
Type: text/x-patch
Size: 1287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160421/0d4aa59a/attachment.bin>
More information about the llvm-commits
mailing list