[llvm-commits] [llvm] r60584 - /llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
Dan Gohman
gohman at apple.com
Thu Dec 4 21:31:14 PST 2008
Author: djg
Date: Thu Dec 4 23:31:14 2008
New Revision: 60584
URL: http://llvm.org/viewvc/llvm-project?rev=60584&view=rev
Log:
Teach StackSlotColoring to update MachineMemOperands when
changing the stack slots on an instruction, to keep them
consistent with the actual memory addresses.
Modified:
llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=60584&r1=60583&r2=60584&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Thu Dec 4 23:31:14 2008
@@ -15,6 +15,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/LiveStackAnalysis.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
@@ -225,10 +226,26 @@
int FI = MO.getIndex();
if (FI < 0)
continue;
- FI = SlotMapping[FI];
- if (FI == -1)
+ int NewFI = SlotMapping[FI];
+ if (NewFI == -1)
continue;
- MO.setIndex(FI);
+ MO.setIndex(NewFI);
+
+ // Update the MachineMemOperand for the new memory location.
+ // FIXME: We need a better method of managing these too.
+ SmallVector<MachineMemOperand, 2> MMOs(MI.memoperands_begin(),
+ MI.memoperands_end());
+ MI.clearMemOperands(MF);
+ const Value *OldSV = PseudoSourceValue::getFixedStack(FI);
+ for (unsigned i = 0, e = MMOs.size(); i != e; ++i) {
+ if (MMOs[i].getValue() == OldSV) {
+ MachineMemOperand MMO(PseudoSourceValue::getFixedStack(NewFI),
+ MMOs[i].getFlags(), MMOs[i].getOffset(),
+ MMOs[i].getSize(), MMOs[i].getAlignment());
+ MI.addMemOperand(MF, MMO);
+ } else
+ MI.addMemOperand(MF, MMOs[i]);
+ }
}
}
}
More information about the llvm-commits
mailing list