[llvm-commits] [llvm] r50167 - in /llvm/trunk/lib/Target/X86: X86RegisterInfo.cpp X86TargetMachine.cpp
Anton Korobeynikov
asl at math.spbu.ru
Wed Apr 23 11:23:30 PDT 2008
Author: asl
Date: Wed Apr 23 13:23:30 2008
New Revision: 50167
URL: http://llvm.org/viewvc/llvm-project?rev=50167&view=rev
Log:
Be over-conservative: scan for all used virtual registers and calculate maximal stack alignment in assumption, that there will be spill of vector register.
Modified:
llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=50167&r1=50166&r2=50167&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Apr 23 13:23:30 2008
@@ -1121,11 +1121,18 @@
virtual bool runOnMachineFunction(MachineFunction &MF) {
MachineFrameInfo *FFI = MF.getFrameInfo();
+ MachineRegisterInfo &RI = MF.getRegInfo();
- // Calculate and set max stack object alignment early, so we can decide
- // whether we will need stack realignment (and thus FP).
+ // Calculate max stack alignment of all already allocated stack objects.
unsigned MaxAlign = calculateMaxStackAlignment(FFI);
+ // Be over-conservative: scan over all vreg defs and find, whether vector
+ // registers are used. If yes - there is probability, that vector register
+ // will be spilled and thus stack needs to be aligned properly.
+ for (unsigned RegNum = TargetRegisterInfo::FirstVirtualRegister;
+ RegNum < RI.getLastVirtReg(); ++RegNum)
+ MaxAlign = std::max(MaxAlign, RI.getRegClass(RegNum)->getAlignment());
+
FFI->setMaxAlignment(MaxAlign);
return false;
Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=50167&r1=50166&r2=50167&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Wed Apr 23 13:23:30 2008
@@ -162,6 +162,8 @@
}
bool X86TargetMachine::addPreRegAlloc(PassManagerBase &PM, bool Fast) {
+ // Calculate and set max stack object alignment early, so we can decide
+ // whether we will need stack realignment (and thus FP).
PM.add(createX86MaxStackAlignmentCalculatorPass());
return false; // -print-machineinstr shouldn't print after this.
}
More information about the llvm-commits
mailing list