[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocSimple.cpp
Misha Brukman
brukman at cs.uiuc.edu
Thu Dec 12 22:35:01 PST 2002
Changes in directory llvm/lib/CodeGen:
RegAllocSimple.cpp updated: 1.6 -> 1.7
---
Log message:
Start allocating stack space at [ebp-4] to not overwrite the return address.
Also make all loads & stores 4-byte aligned for performance. ;)
---
Diffs of the changes:
Index: llvm/lib/CodeGen/RegAllocSimple.cpp
diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.6 llvm/lib/CodeGen/RegAllocSimple.cpp:1.7
--- llvm/lib/CodeGen/RegAllocSimple.cpp:1.6 Thu Dec 12 17:20:31 2002
+++ llvm/lib/CodeGen/RegAllocSimple.cpp Thu Dec 12 22:34:02 2002
@@ -50,13 +50,15 @@
RegAllocSimple(TargetMachine &tm) : TM(tm), CurrMBB(0), maxOffset(0),
RegInfo(tm.getRegisterInfo()),
- NumBytesAllocated(0), ByteAlignment(4)
+ ByteAlignment(4)
{
// build reverse mapping for physReg -> register class
RegInfo->buildReg2RegClassMap(PhysReg2RegClassMap);
RegsUsed[RegInfo->getFramePointer()] = 1;
RegsUsed[RegInfo->getStackPointer()] = 1;
+
+ cleanupAfterFunction();
}
bool isAvailableReg(unsigned Reg) {
@@ -80,7 +82,7 @@
void cleanupAfterFunction() {
RegMap.clear();
SSA2PhysRegMap.clear();
- NumBytesAllocated = 0;
+ NumBytesAllocated = 4;
}
/// Moves value from memory into that register
@@ -112,6 +114,7 @@
const TargetRegisterClass *regClass)
{
if (RegMap.find(VirtReg) == RegMap.end()) {
+#if 0
unsigned size = regClass->getDataSize();
unsigned over = NumBytesAllocated - (NumBytesAllocated % ByteAlignment);
if (size >= ByteAlignment - over) {
@@ -120,6 +123,10 @@
}
RegMap[VirtReg] = NumBytesAllocated;
NumBytesAllocated += size;
+#endif
+ // FIXME: forcing each arg to take 4 bytes on the stack
+ RegMap[VirtReg] = NumBytesAllocated;
+ NumBytesAllocated += 4;
}
return RegMap[VirtReg];
}
More information about the llvm-commits
mailing list