forked from OSchip/llvm-project
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. llvm-svn: 158758
This commit is contained in:
parent
39fb1d08dc
commit
7369692790
|
@ -359,7 +359,7 @@ public:
|
||||||
assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
|
assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
|
||||||
"Invalid Object Idx!");
|
"Invalid Object Idx!");
|
||||||
Objects[ObjectIdx+NumFixedObjects].Alignment = Align;
|
Objects[ObjectIdx+NumFixedObjects].Alignment = Align;
|
||||||
MaxAlignment = std::max(MaxAlignment, Align);
|
ensureMaxAlignment(Align);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// NeedsStackProtector - Returns true if the object may need stack
|
/// NeedsStackProtector - Returns true if the object may need stack
|
||||||
|
@ -416,9 +416,11 @@ public:
|
||||||
///
|
///
|
||||||
unsigned getMaxAlignment() const { return MaxAlignment; }
|
unsigned getMaxAlignment() const { return MaxAlignment; }
|
||||||
|
|
||||||
/// setMaxAlignment - Set the preferred alignment.
|
/// ensureMaxAlignment - Make sure the function is at least Align bytes
|
||||||
///
|
/// aligned.
|
||||||
void setMaxAlignment(unsigned Align) { MaxAlignment = Align; }
|
void ensureMaxAlignment(unsigned Align) {
|
||||||
|
if (MaxAlignment < Align) MaxAlignment = Align;
|
||||||
|
}
|
||||||
|
|
||||||
/// AdjustsStack - Return true if this function adjusts the stack -- e.g.,
|
/// AdjustsStack - Return true if this function adjusts the stack -- e.g.,
|
||||||
/// when calling another function. This is only valid during and after
|
/// when calling another function. This is only valid during and after
|
||||||
|
@ -485,7 +487,7 @@ public:
|
||||||
Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, MayNeedSP));
|
Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, MayNeedSP));
|
||||||
int Index = (int)Objects.size() - NumFixedObjects - 1;
|
int Index = (int)Objects.size() - NumFixedObjects - 1;
|
||||||
assert(Index >= 0 && "Bad frame index!");
|
assert(Index >= 0 && "Bad frame index!");
|
||||||
MaxAlignment = std::max(MaxAlignment, Alignment);
|
ensureMaxAlignment(Alignment);
|
||||||
return Index;
|
return Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +498,7 @@ public:
|
||||||
int CreateSpillStackObject(uint64_t Size, unsigned Alignment) {
|
int CreateSpillStackObject(uint64_t Size, unsigned Alignment) {
|
||||||
CreateStackObject(Size, Alignment, true, false);
|
CreateStackObject(Size, Alignment, true, false);
|
||||||
int Index = (int)Objects.size() - NumFixedObjects - 1;
|
int Index = (int)Objects.size() - NumFixedObjects - 1;
|
||||||
MaxAlignment = std::max(MaxAlignment, Alignment);
|
ensureMaxAlignment(Alignment);
|
||||||
return Index;
|
return Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +517,7 @@ public:
|
||||||
int CreateVariableSizedObject(unsigned Alignment) {
|
int CreateVariableSizedObject(unsigned Alignment) {
|
||||||
HasVarSizedObjects = true;
|
HasVarSizedObjects = true;
|
||||||
Objects.push_back(StackObject(0, Alignment, 0, false, false, true));
|
Objects.push_back(StackObject(0, Alignment, 0, false, false, true));
|
||||||
MaxAlignment = std::max(MaxAlignment, Alignment);
|
ensureMaxAlignment(Alignment);
|
||||||
return (int)Objects.size()-NumFixedObjects-1;
|
return (int)Objects.size()-NumFixedObjects-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,7 @@ void CCState::HandleByVal(unsigned ValNo, MVT ValVT,
|
||||||
Size = MinSize;
|
Size = MinSize;
|
||||||
if (MinAlign > (int)Align)
|
if (MinAlign > (int)Align)
|
||||||
Align = MinAlign;
|
Align = MinAlign;
|
||||||
if (MF.getFrameInfo()->getMaxAlignment() < Align)
|
MF.getFrameInfo()->ensureMaxAlignment(Align);
|
||||||
MF.getFrameInfo()->setMaxAlignment(Align);
|
|
||||||
TM.getTargetLowering()->HandleByVal(this, Size);
|
TM.getTargetLowering()->HandleByVal(this, Size);
|
||||||
unsigned Offset = AllocateStack(Size, Align);
|
unsigned Offset = AllocateStack(Size, Align);
|
||||||
addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
|
addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
|
||||||
|
|
|
@ -60,7 +60,7 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
|
||||||
MFInfo = 0;
|
MFInfo = 0;
|
||||||
FrameInfo = new (Allocator) MachineFrameInfo(*TM.getFrameLowering());
|
FrameInfo = new (Allocator) MachineFrameInfo(*TM.getFrameLowering());
|
||||||
if (Fn->hasFnAttr(Attribute::StackAlignment))
|
if (Fn->hasFnAttr(Attribute::StackAlignment))
|
||||||
FrameInfo->setMaxAlignment(Attribute::getStackAlignmentFromAttrs(
|
FrameInfo->ensureMaxAlignment(Attribute::getStackAlignmentFromAttrs(
|
||||||
Fn->getAttributes().getFnAttributes()));
|
Fn->getAttributes().getFnAttributes()));
|
||||||
ConstantPool = new (Allocator) MachineConstantPool(TM.getTargetData());
|
ConstantPool = new (Allocator) MachineConstantPool(TM.getTargetData());
|
||||||
Alignment = TM.getTargetLowering()->getMinFunctionAlignment();
|
Alignment = TM.getTargetLowering()->getMinFunctionAlignment();
|
||||||
|
|
Loading…
Reference in New Issue