[llvm-commits] [llvm] r116210 - /llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Oct 11 11:10:36 PDT 2010
Author: stoklund
Date: Mon Oct 11 13:10:36 2010
New Revision: 116210
URL: http://llvm.org/viewvc/llvm-project?rev=116210&view=rev
Log:
Properly handle reloading and spilling around partial redefines in
LocalRewriter.
This is a bit of a hack that adds an implicit use operand to model the
read-modify-write nature of a partial redef. Uses and defs are rewritten in
separate passes, and a single operand would never be processed twice.
<rdar://problem/8518892>
Modified:
llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=116210&r1=116209&r2=116210&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Mon Oct 11 13:10:36 2010
@@ -1894,6 +1894,20 @@
VirtUseOps.insert(VirtUseOps.begin(), i);
else
VirtUseOps.push_back(i);
+
+ // A partial def causes problems because the same operand both reads and
+ // writes the register. This rewriter is designed to rewrite uses and defs
+ // separately, so a partial def would already have been rewritten to a
+ // physreg by the time we get to processing defs.
+ // Add an implicit use operand to model the partial def.
+ if (MO.isDef() && MO.getSubReg() && MI.readsVirtualRegister(VirtReg) &&
+ MI.findRegisterUseOperandIdx(VirtReg) == -1) {
+ VirtUseOps.insert(VirtUseOps.begin(), MI.getNumOperands());
+ MI.addOperand(MachineOperand::CreateReg(VirtReg,
+ false, // isDef
+ true)); // isImplicit
+ DEBUG(dbgs() << "Partial redef: " << MI);
+ }
}
// Process all of the spilled uses and all non spilled reg references.
More information about the llvm-commits
mailing list