[llvm-branch-commits] [llvm-branch] r95247 - in /llvm/branches/Apple/Zoidberg: include/llvm/CodeGen/Passes.h lib/CodeGen/MaxStackAlignment.cpp lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMBaseRegisterInfo.h lib/Target/ARM/ARMTargetMachine.cpp lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86RegisterInfo.cpp lib/Target/X86/X86RegisterInfo.h lib/Target/X86/X86TargetMachine.cpp

Bob Wilson bob.wilson at apple.com
Wed Feb 3 12:49:12 PST 2010


Author: bwilson
Date: Wed Feb  3 14:49:12 2010
New Revision: 95247

URL: http://llvm.org/viewvc/llvm-project?rev=95247&view=rev
Log:
--- Merging r93885 into '.':
U    include/llvm/CodeGen/Passes.h
D    lib/CodeGen/MaxStackAlignment.cpp
U    lib/Target/ARM/ARMTargetMachine.cpp
U    lib/Target/ARM/ARMBaseRegisterInfo.h
U    lib/Target/ARM/ARMBaseRegisterInfo.cpp
U    lib/Target/ARM/ARMBaseInstrInfo.cpp
U    lib/Target/X86/X86RegisterInfo.cpp
U    lib/Target/X86/X86RegisterInfo.h
U    lib/Target/X86/X86InstrInfo.cpp
U    lib/Target/X86/X86TargetMachine.cpp

Removed:
    llvm/branches/Apple/Zoidberg/lib/CodeGen/MaxStackAlignment.cpp
Modified:
    llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h
    llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp
    llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp
    llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.h
    llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp
    llvm/branches/Apple/Zoidberg/lib/Target/X86/X86InstrInfo.cpp
    llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp
    llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.h
    llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp

Modified: llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h Wed Feb  3 14:49:12 2010
@@ -191,10 +191,6 @@
   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
 
-  /// createMaxStackAlignmentCalculatorPass() - Determine the maximum required
-  /// alignment for a function.
-  FunctionPass* createMaxStackAlignmentCalculatorPass();
-
 } // End llvm namespace
 
 #endif

Removed: llvm/branches/Apple/Zoidberg/lib/CodeGen/MaxStackAlignment.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/MaxStackAlignment.cpp?rev=95246&view=auto

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/MaxStackAlignment.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/MaxStackAlignment.cpp (removed)
@@ -1,70 +0,0 @@
-//===-- MaxStackAlignment.cpp - Compute the required stack alignment -- ---===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass looks for vector register usage and aligned local objects to
-// calculate the maximum required alignment for a function. This is used by
-// targets which support it to determine if dynamic stack realignment is
-// necessary.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/CodeGen/Passes.h"
-
-using namespace llvm;
-
-namespace {
-  struct MaximalStackAlignmentCalculator : public MachineFunctionPass {
-    static char ID;
-    MaximalStackAlignmentCalculator() : MachineFunctionPass(&ID) {}
-
-    virtual bool runOnMachineFunction(MachineFunction &MF) {
-      MachineFrameInfo *FFI = MF.getFrameInfo();
-      MachineRegisterInfo &RI = MF.getRegInfo();
-
-      // Calculate max stack alignment of all already allocated stack objects.
-      FFI->calculateMaxStackAlignment();
-      unsigned MaxAlign = FFI->getMaxAlignment();
-
-      // Be over-conservative: scan over all vreg defs and find whether vector
-      // registers are used. If yes, there is probability that vector registers
-      // will be spilled and thus the stack needs to be aligned properly.
-      // FIXME: It would be better to only do this if a spill actually
-      // happens rather than conseratively aligning the stack regardless.
-      for (unsigned RegNum = TargetRegisterInfo::FirstVirtualRegister;
-           RegNum < RI.getLastVirtReg(); ++RegNum)
-        MaxAlign = std::max(MaxAlign, RI.getRegClass(RegNum)->getAlignment());
-
-      if (FFI->getMaxAlignment() == MaxAlign)
-        return false;
-
-      FFI->setMaxAlignment(MaxAlign);
-      return true;
-    }
-
-    virtual const char *getPassName() const {
-      return "Stack Alignment Requirements Auto-Detector";
-    }
-
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.setPreservesCFG();
-      MachineFunctionPass::getAnalysisUsage(AU);
-    }
-  };
-
-  char MaximalStackAlignmentCalculator::ID = 0;
-}
-
-FunctionPass*
-llvm::createMaxStackAlignmentCalculatorPass() {
-  return new MaximalStackAlignmentCalculator();
-}
-

Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp Wed Feb  3 14:49:12 2010
@@ -713,7 +713,7 @@
             RC == ARM::QPR_VFP2RegisterClass) && "Unknown regclass!");
     // FIXME: Neon instructions should support predicates
     if (Align >= 16
-        && (getRegisterInfo().needsStackRealignment(MF))) {
+        && (getRegisterInfo().canRealignStack(MF))) {
       AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::VST1q64))
                      .addFrameIndex(FI).addImm(0).addImm(0).addImm(128)
                      .addMemOperand(MMO)
@@ -759,7 +759,7 @@
             RC == ARM::QPR_8RegisterClass) && "Unknown regclass!");
     // FIXME: Neon instructions should support predicates
     if (Align >= 16
-        && (getRegisterInfo().needsStackRealignment(MF))) {
+        && (getRegisterInfo().canRealignStack(MF))) {
       AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::VLD1q64), DestReg)
                      .addFrameIndex(FI).addImm(0).addImm(0).addImm(128)
                      .addMemOperand(MMO));

Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Feb  3 14:49:12 2010
@@ -484,6 +484,14 @@
           MFI->isFrameAddressTaken());
 }
 
+bool ARMBaseRegisterInfo::canRealignStack(const MachineFunction &MF) const {
+  const MachineFrameInfo *MFI = MF.getFrameInfo();
+  const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
+  return (RealignStack &&
+          !AFI->isThumb1OnlyFunction() &&
+          !MFI->hasVarSizedObjects());
+}
+
 bool ARMBaseRegisterInfo::
 needsStackRealignment(const MachineFunction &MF) const {
   const MachineFrameInfo *MFI = MF.getFrameInfo();

Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.h (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.h Wed Feb  3 14:49:12 2010
@@ -96,6 +96,7 @@
 
   bool hasFP(const MachineFunction &MF) const;
 
+  bool canRealignStack(const MachineFunction &MF) const;
   bool needsStackRealignment(const MachineFunction &MF) const;
 
   bool cannotEliminateFrame(const MachineFunction &MF) const;

Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp Wed Feb  3 14:49:12 2010
@@ -93,10 +93,6 @@
   if (Subtarget.hasNEON())
     PM.add(createNEONPreAllocPass());
 
-  // Calculate and set max stack object alignment early, so we can decide
-  // whether we will need stack realignment (and thus FP).
-  PM.add(createMaxStackAlignmentCalculatorPass());
-
   // FIXME: temporarily disabling load / store optimization pass for Thumb1.
   if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
     PM.add(createARMLoadStoreOptimizationPass(true));

Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86InstrInfo.cpp?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86InstrInfo.cpp Wed Feb  3 14:49:12 2010
@@ -2001,8 +2001,7 @@
                                        unsigned SrcReg, bool isKill, int FrameIdx,
                                        const TargetRegisterClass *RC) const {
   const MachineFunction &MF = *MBB.getParent();
-  bool isAligned = (RI.getStackAlignment() >= 16) ||
-    RI.needsStackRealignment(MF);
+  bool isAligned = (RI.getStackAlignment() >= 16) || RI.canRealignStack(MF);
   unsigned Opc = getStoreRegOpcode(SrcReg, RC, isAligned, TM);
   DebugLoc DL = DebugLoc::getUnknownLoc();
   if (MI != MBB.end()) DL = MI->getDebugLoc();
@@ -2096,8 +2095,7 @@
                                         unsigned DestReg, int FrameIdx,
                                         const TargetRegisterClass *RC) const{
   const MachineFunction &MF = *MBB.getParent();
-  bool isAligned = (RI.getStackAlignment() >= 16) ||
-    RI.needsStackRealignment(MF);
+  bool isAligned = (RI.getStackAlignment() >= 16) || RI.canRealignStack(MF);
   unsigned Opc = getLoadRegOpcode(DestReg, RC, isAligned, TM);
   DebugLoc DL = DebugLoc::getUnknownLoc();
   if (MI != MBB.end()) DL = MI->getDebugLoc();

Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp Wed Feb  3 14:49:12 2010
@@ -438,6 +438,12 @@
           (MMI && MMI->callsUnwindInit()));
 }
 
+bool X86RegisterInfo::canRealignStack(const MachineFunction &MF) const {
+  const MachineFrameInfo *MFI = MF.getFrameInfo();
+  return (RealignStack &&
+          !MFI->hasVarSizedObjects());
+}
+
 bool X86RegisterInfo::needsStackRealignment(const MachineFunction &MF) const {
   const MachineFrameInfo *MFI = MF.getFrameInfo();
   bool requiresRealignment =

Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.h?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.h (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.h Wed Feb  3 14:49:12 2010
@@ -128,6 +128,8 @@
 
   bool hasFP(const MachineFunction &MF) const;
 
+  bool canRealignStack(const MachineFunction &MF) const;
+
   bool needsStackRealignment(const MachineFunction &MF) const;
 
   bool hasReservedCallFrame(MachineFunction &MF) const;

Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp?rev=95247&r1=95246&r2=95247&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp Wed Feb  3 14:49:12 2010
@@ -157,9 +157,6 @@
 
 bool X86TargetMachine::addPreRegAlloc(PassManagerBase &PM,
                                       CodeGenOpt::Level OptLevel) {
-  // Calculate and set max stack object alignment early, so we can decide
-  // whether we will need stack realignment (and thus FP).
-  PM.add(createMaxStackAlignmentCalculatorPass());
   return false;  // -print-machineinstr shouldn't print after this.
 }
 





More information about the llvm-branch-commits mailing list