aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocLinearScan.cpp
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-02-03 01:13:07 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-02-03 01:13:07 +0000
commit4e7854407ced8e2160592675918312a20cfb7cde (patch)
treeda0f658db536c6cd06029a0d3c1e0e5a967cdc47 /lib/CodeGen/RegAllocLinearScan.cpp
parent9fe7602862328c0081106709e0a8f03316dc845b (diff)
When an instruction like: A += B had both A and B virtual registers
spilled, A was loaded from its stack location twice. This fixes the bug. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLinearScan.cpp')
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index 26c1417fa0..b71a138616 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -470,7 +470,8 @@ bool RA::runOnMachineFunction(MachineFunction &fn) {
for (unsigned i = 0, e = (*currentInstr_)->getNumOperands();
i != e; ++i) {
MachineOperand& op = (*currentInstr_)->getOperand(i);
- if (op.isVirtualRegister() && op.isUse() && !op.isDef()) {
+ if (op.isVirtualRegister() && op.isUse() &&
+ !op.isEverDefined(**currentInstr_)) {
unsigned virtReg = op.getAllocatedRegNum();
unsigned physReg = 0;
Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg);
@@ -497,7 +498,9 @@ bool RA::runOnMachineFunction(MachineFunction &fn) {
for (unsigned i = 0, e = (*currentInstr_)->getNumOperands();
i != e; ++i) {
MachineOperand& op = (*currentInstr_)->getOperand(i);
- if (op.isVirtualRegister() && op.isDef()) {
+ if (op.isVirtualRegister()) {
+ assert(op.isEverDefined(**currentInstr_) &&
+ "operand should be defined by this instruction");
unsigned virtReg = op.getAllocatedRegNum();
unsigned physReg = 0;
Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg);
@@ -506,14 +509,9 @@ bool RA::runOnMachineFunction(MachineFunction &fn) {
}
else {
physReg = getFreeTempPhysReg(virtReg);
- }
- if (op.isUse()) { // def and use
- loadVirt2PhysReg(virtReg, physReg);
- }
- else {
assignVirt2PhysReg(virtReg, physReg);
+ tempDefOperands_.push_back(virtReg);
}
- tempDefOperands_.push_back(virtReg);
(*currentInstr_)->SetMachineOperandReg(i, physReg);
}
}
@@ -815,8 +813,6 @@ void RA::assignVirt2StackSlot(unsigned virtReg)
int RA::getStackSlot(unsigned virtReg)
{
- // use lower_bound so that we can do a possibly O(1) insert later
- // if necessary
Virt2StackSlotMap::iterator it = v2ssMap_.find(virtReg);
assert(it != v2ssMap_.end() &&
"attempt to get stack slot on register that does not live on the stack");