diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-10-11 18:10:36 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-10-11 18:10:36 +0000 |
commit | 2f6531eb8cec7cb918245377229b29578b52564c (patch) | |
tree | 0b8b93615b6c8dc440f8000865bd35987ed1579d | |
parent | db3bc40ade6ad98a7ff3df35789dc51841ff4392 (diff) | |
download | bcm5719-llvm-2f6531eb8cec7cb918245377229b29578b52564c.tar.gz bcm5719-llvm-2f6531eb8cec7cb918245377229b29578b52564c.zip |
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>
llvm-svn: 116210
-rw-r--r-- | llvm/lib/CodeGen/VirtRegRewriter.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/VirtRegRewriter.cpp b/llvm/lib/CodeGen/VirtRegRewriter.cpp index f44eccd40cc..5baedb98db1 100644 --- a/llvm/lib/CodeGen/VirtRegRewriter.cpp +++ b/llvm/lib/CodeGen/VirtRegRewriter.cpp @@ -1894,6 +1894,20 @@ void LocalRewriter::ProcessUses(MachineInstr &MI, AvailableSpills &Spills, 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. |