Update the .cvs files.
[oota-llvm.git] / lib / Target / X86 / X86RegisterInfo.cpp
index 2b14f6eb9b80735aab78b0c661830345944efd93..0bac85094ca524da6fb61e17195dc1228b6cf8c7 100644 (file)
@@ -283,7 +283,7 @@ bool X86RegisterInfo::needsStackRealignment(const MachineFunction &MF) const {
 
   // FIXME: Currently we don't support stack realignment for functions with
   // variable-sized allocas
-  return (MFI->getMaxAlignment() &&
+  return (RealignStack &&
           (MFI->getMaxAlignment() > StackAlign &&
            !MFI->hasVarSizedObjects()));
 }
@@ -417,7 +417,8 @@ X86RegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
 
   // Calculate and set max stack object alignment early, so we can decide
   // whether we will need stack realignment (and thus FP).
-  unsigned MaxAlign = calculateMaxStackAlignment(FFI);
+  unsigned MaxAlign = std::max(FFI->getMaxAlignment(),
+                               calculateMaxStackAlignment(FFI));
 
   FFI->setMaxAlignment(MaxAlign);
 }
@@ -945,8 +946,8 @@ unsigned X86RegisterInfo::getEHHandlerRegister() const {
 }
 
 namespace llvm {
-unsigned getX86SubSuperRegister(unsigned Reg, MVT::ValueType VT, bool High) {
-  switch (VT) {
+unsigned getX86SubSuperRegister(unsigned Reg, MVT VT, bool High) {
+  switch (VT.getSimpleVT()) {
   default: return Reg;
   case MVT::i8:
     if (High) {
@@ -1121,11 +1122,18 @@ namespace {
 
     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;