[llvm-commits] [llvm] r158758 - in /llvm/trunk: include/llvm/CodeGen/MachineFrameInfo.h lib/CodeGen/CallingConvLower.cpp lib/CodeGen/MachineFunction.cpp
Chad Rosier
mcrosier at apple.com
Tue Jun 19 15:59:12 PDT 2012
Author: mcrosier
Date: Tue Jun 19 17:59:12 2012
New Revision: 158758
URL: http://llvm.org/viewvc/llvm-project?rev=158758&view=rev
Log:
Add an ensureMaxAlignment() function to MachineFrameInfo (analogous to
ensureAlignment() in MachineFunction). Also, drop setMaxAlignment() in
favor of this new function. This creates a main entry point to setting
MaxAlignment, which will be helpful for future work. No functionality
change intended.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
llvm/trunk/lib/CodeGen/CallingConvLower.cpp
llvm/trunk/lib/CodeGen/MachineFunction.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=158758&r1=158757&r2=158758&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Tue Jun 19 17:59:12 2012
@@ -359,7 +359,7 @@
assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
"Invalid Object Idx!");
Objects[ObjectIdx+NumFixedObjects].Alignment = Align;
- MaxAlignment = std::max(MaxAlignment, Align);
+ ensureMaxAlignment(Align);
}
/// NeedsStackProtector - Returns true if the object may need stack
@@ -416,9 +416,11 @@
///
unsigned getMaxAlignment() const { return MaxAlignment; }
- /// setMaxAlignment - Set the preferred alignment.
- ///
- void setMaxAlignment(unsigned Align) { MaxAlignment = Align; }
+ /// ensureMaxAlignment - Make sure the function is at least Align bytes
+ /// aligned.
+ void ensureMaxAlignment(unsigned Align) {
+ if (MaxAlignment < Align) MaxAlignment = Align;
+ }
/// AdjustsStack - Return true if this function adjusts the stack -- e.g.,
/// when calling another function. This is only valid during and after
@@ -485,7 +487,7 @@
Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, MayNeedSP));
int Index = (int)Objects.size() - NumFixedObjects - 1;
assert(Index >= 0 && "Bad frame index!");
- MaxAlignment = std::max(MaxAlignment, Alignment);
+ ensureMaxAlignment(Alignment);
return Index;
}
@@ -496,7 +498,7 @@
int CreateSpillStackObject(uint64_t Size, unsigned Alignment) {
CreateStackObject(Size, Alignment, true, false);
int Index = (int)Objects.size() - NumFixedObjects - 1;
- MaxAlignment = std::max(MaxAlignment, Alignment);
+ ensureMaxAlignment(Alignment);
return Index;
}
@@ -515,7 +517,7 @@
int CreateVariableSizedObject(unsigned Alignment) {
HasVarSizedObjects = true;
Objects.push_back(StackObject(0, Alignment, 0, false, false, true));
- MaxAlignment = std::max(MaxAlignment, Alignment);
+ ensureMaxAlignment(Alignment);
return (int)Objects.size()-NumFixedObjects-1;
}
Modified: llvm/trunk/lib/CodeGen/CallingConvLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CallingConvLower.cpp?rev=158758&r1=158757&r2=158758&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CallingConvLower.cpp (original)
+++ llvm/trunk/lib/CodeGen/CallingConvLower.cpp Tue Jun 19 17:59:12 2012
@@ -49,8 +49,7 @@
Size = MinSize;
if (MinAlign > (int)Align)
Align = MinAlign;
- if (MF.getFrameInfo()->getMaxAlignment() < Align)
- MF.getFrameInfo()->setMaxAlignment(Align);
+ MF.getFrameInfo()->ensureMaxAlignment(Align);
TM.getTargetLowering()->HandleByVal(this, Size);
unsigned Offset = AllocateStack(Size, Align);
addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=158758&r1=158757&r2=158758&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Tue Jun 19 17:59:12 2012
@@ -60,7 +60,7 @@
MFInfo = 0;
FrameInfo = new (Allocator) MachineFrameInfo(*TM.getFrameLowering());
if (Fn->hasFnAttr(Attribute::StackAlignment))
- FrameInfo->setMaxAlignment(Attribute::getStackAlignmentFromAttrs(
+ FrameInfo->ensureMaxAlignment(Attribute::getStackAlignmentFromAttrs(
Fn->getAttributes().getFnAttributes()));
ConstantPool = new (Allocator) MachineConstantPool(TM.getTargetData());
Alignment = TM.getTargetLowering()->getMinFunctionAlignment();
More information about the llvm-commits
mailing list