[llvm-branch-commits] [llvm-branch] r90338 - in /llvm/branches/Apple/Zoidberg: include/llvm/CodeGen/MachineFrameInfo.h include/llvm/CodeGen/Passes.h lib/CodeGen/MaxStackAlignment.cpp lib/Target/ARM/ARM.h lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMTargetMachine.cpp lib/Target/X86/X86.h lib/Target/X86/X86RegisterInfo.cpp lib/Target/X86/X86TargetMachine.cpp
Jim Grosbach
grosbach at apple.com
Wed Dec 2 11:33:20 PST 2009
Author: grosbach
Date: Wed Dec 2 13:33:19 2009
New Revision: 90338
URL: http://llvm.org/viewvc/llvm-project?rev=90338&view=rev
Log:
merge 90336
Added:
llvm/branches/Apple/Zoidberg/lib/CodeGen/MaxStackAlignment.cpp
- copied unchanged from r90336, llvm/trunk/lib/CodeGen/MaxStackAlignment.cpp
Modified:
llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/MachineFrameInfo.h
llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h
llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARM.h
llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp
llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp
llvm/branches/Apple/Zoidberg/lib/Target/X86/X86.h
llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp
llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/MachineFrameInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/MachineFrameInfo.h?rev=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/MachineFrameInfo.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/MachineFrameInfo.h Wed Dec 2 13:33:19 2009
@@ -327,7 +327,20 @@
/// setMaxAlignment - Set the preferred alignment.
///
void setMaxAlignment(unsigned Align) { MaxAlignment = Align; }
-
+
+ /// calculateMaxStackAlignment() - If there is a local object which requires
+ /// greater alignment than the current max alignment, adjust accordingly.
+ void calculateMaxStackAlignment() {
+ for (int i = getObjectIndexBegin(),
+ e = getObjectIndexEnd(); i != e; ++i) {
+ if (isDeadObjectIndex(i))
+ continue;
+
+ unsigned Align = getObjectAlignment(i);
+ MaxAlignment = std::max(MaxAlignment, Align);
+ }
+ }
+
/// hasCalls - Return true if the current function has no function calls.
/// This is only valid during or after prolog/epilog code emission.
///
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=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/CodeGen/Passes.h Wed Dec 2 13:33:19 2009
@@ -191,6 +191,10 @@
/// 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
Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARM.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARM.h?rev=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARM.h (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARM.h Wed Dec 2 13:33:19 2009
@@ -109,7 +109,6 @@
FunctionPass *createNEONMoveFixPass();
FunctionPass *createThumb2ITBlockPass();
FunctionPass *createThumb2SizeReductionPass();
-FunctionPass *createARMMaxStackAlignmentCalculatorPass();
extern Target TheARMTarget, TheThumbTarget;
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=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Dec 2 13:33:19 2009
@@ -471,21 +471,6 @@
}
}
-static unsigned calculateMaxStackAlignment(const MachineFrameInfo *FFI) {
- unsigned MaxAlign = 0;
-
- for (int i = FFI->getObjectIndexBegin(),
- e = FFI->getObjectIndexEnd(); i != e; ++i) {
- if (FFI->isDeadObjectIndex(i))
- continue;
-
- unsigned Align = FFI->getObjectAlignment(i);
- MaxAlign = std::max(MaxAlign, Align);
- }
-
- return MaxAlign;
-}
-
/// hasFP - Return true if the specified function should have a dedicated frame
/// pointer register. This is true if the function has variable sized allocas
/// or if frame pointer elimination is disabled.
@@ -585,14 +570,12 @@
SmallVector<unsigned, 4> UnspilledCS2GPRs;
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
- MachineFrameInfo *MFI = MF.getFrameInfo();
// Calculate and set max stack object alignment early, so we can decide
// whether we will need stack realignment (and thus FP).
if (RealignStack) {
- unsigned MaxAlign = std::max(MFI->getMaxAlignment(),
- calculateMaxStackAlignment(MFI));
- MFI->setMaxAlignment(MaxAlign);
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ MFI->calculateMaxStackAlignment();
}
// Don't spill FP if the frame can be eliminated. This is determined
@@ -1479,48 +1462,4 @@
emitSPUpdate(isARM, MBB, MBBI, dl, TII, VARegSaveSize);
}
-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.
- 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());
-
- if (FFI->getMaxAlignment() == MaxAlign)
- return false;
-
- FFI->setMaxAlignment(MaxAlign);
- return true;
- }
-
- virtual const char *getPassName() const {
- return "ARM Stack Required Alignment Auto-Detector";
- }
-
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesCFG();
- MachineFunctionPass::getAnalysisUsage(AU);
- }
- };
-
- char MaximalStackAlignmentCalculator::ID = 0;
-}
-
-FunctionPass*
-llvm::createARMMaxStackAlignmentCalculatorPass() {
- return new MaximalStackAlignmentCalculator();
-}
-
#include "ARMGenRegisterInfo.inc"
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=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMTargetMachine.cpp Wed Dec 2 13:33:19 2009
@@ -95,7 +95,7 @@
// Calculate and set max stack object alignment early, so we can decide
// whether we will need stack realignment (and thus FP).
- PM.add(createARMMaxStackAlignmentCalculatorPass());
+ PM.add(createMaxStackAlignmentCalculatorPass());
// FIXME: temporarily disabling load / store optimization pass for Thumb1.
if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86.h?rev=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86.h (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86.h Wed Dec 2 13:33:19 2009
@@ -62,11 +62,6 @@
///
FunctionPass *createEmitX86CodeToMemory();
-/// createX86MaxStackAlignmentCalculatorPass - This function returns a pass
-/// which calculates maximal stack alignment required for function
-///
-FunctionPass *createX86MaxStackAlignmentCalculatorPass();
-
extern Target TheX86_32Target, TheX86_64Target;
} // End llvm namespace
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=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86RegisterInfo.cpp Wed Dec 2 13:33:19 2009
@@ -423,21 +423,6 @@
// Stack Frame Processing methods
//===----------------------------------------------------------------------===//
-static unsigned calculateMaxStackAlignment(const MachineFrameInfo *FFI) {
- unsigned MaxAlign = 0;
-
- for (int i = FFI->getObjectIndexBegin(),
- e = FFI->getObjectIndexEnd(); i != e; ++i) {
- if (FFI->isDeadObjectIndex(i))
- continue;
-
- unsigned Align = FFI->getObjectAlignment(i);
- MaxAlign = std::max(MaxAlign, Align);
- }
-
- return MaxAlign;
-}
-
/// hasFP - Return true if the specified function should have a dedicated frame
/// pointer register. This is true if the function has variable sized allocas
/// or if frame pointer elimination is disabled.
@@ -638,10 +623,7 @@
// Calculate and set max stack object alignment early, so we can decide
// whether we will need stack realignment (and thus FP).
- unsigned MaxAlign = std::max(MFI->getMaxAlignment(),
- calculateMaxStackAlignment(MFI));
-
- MFI->setMaxAlignment(MaxAlign);
+ MFI->calculateMaxStackAlignment();
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
int32_t TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
@@ -1482,45 +1464,3 @@
}
#include "X86GenRegisterInfo.inc"
-
-namespace {
- struct MSAC : public MachineFunctionPass {
- static char ID;
- MSAC() : 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.
- 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());
-
- if (FFI->getMaxAlignment() == MaxAlign)
- return false;
-
- FFI->setMaxAlignment(MaxAlign);
- return true;
- }
-
- virtual const char *getPassName() const {
- return "X86 Maximal Stack Alignment Calculator";
- }
-
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesCFG();
- MachineFunctionPass::getAnalysisUsage(AU);
- }
- };
-
- char MSAC::ID = 0;
-}
-
-FunctionPass*
-llvm::createX86MaxStackAlignmentCalculatorPass() { return new MSAC(); }
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=90338&r1=90337&r2=90338&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp Wed Dec 2 13:33:19 2009
@@ -163,7 +163,7 @@
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(createX86MaxStackAlignmentCalculatorPass());
+ PM.add(createMaxStackAlignmentCalculatorPass());
return false; // -print-machineinstr shouldn't print after this.
}
More information about the llvm-branch-commits
mailing list