mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
Teach MachineFrameInfo to track maximum alignment while stack objects are being
created. This ensures it's updated at all time. It means targets which perform dynamic stack alignment would know whether it is required and whether frame pointer register cannot be made available register allocation. This is a fix for rdar://7625239. Sorry, I can't create a reasonably sized test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96069 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f0907fe590
commit
7545f49a5e
@ -276,6 +276,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getObjectOffset - Return the assigned stack offset of the specified object
|
/// getObjectOffset - Return the assigned stack offset of the specified object
|
||||||
@ -328,19 +329,6 @@ public:
|
|||||||
///
|
///
|
||||||
void setMaxAlignment(unsigned Align) { MaxAlignment = Align; }
|
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.
|
/// hasCalls - Return true if the current function has no function calls.
|
||||||
/// This is only valid during or after prolog/epilog code emission.
|
/// This is only valid during or after prolog/epilog code emission.
|
||||||
///
|
///
|
||||||
@ -402,6 +390,7 @@ public:
|
|||||||
Objects.push_back(StackObject(Size, Alignment, 0, false, isSS));
|
Objects.push_back(StackObject(Size, Alignment, 0, false, isSS));
|
||||||
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);
|
||||||
return Index;
|
return Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,6 +401,7 @@ public:
|
|||||||
int CreateSpillStackObject(uint64_t Size, unsigned Alignment) {
|
int CreateSpillStackObject(uint64_t Size, unsigned Alignment) {
|
||||||
CreateStackObject(Size, Alignment, true);
|
CreateStackObject(Size, Alignment, true);
|
||||||
int Index = (int)Objects.size()-NumFixedObjects-1;
|
int Index = (int)Objects.size()-NumFixedObjects-1;
|
||||||
|
MaxAlignment = std::max(MaxAlignment, Alignment);
|
||||||
return Index;
|
return Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,8 +476,6 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
|
|||||||
// Loop over all of the stack objects, assigning sequential addresses...
|
// Loop over all of the stack objects, assigning sequential addresses...
|
||||||
MachineFrameInfo *FFI = Fn.getFrameInfo();
|
MachineFrameInfo *FFI = Fn.getFrameInfo();
|
||||||
|
|
||||||
unsigned MaxAlign = 1;
|
|
||||||
|
|
||||||
// Start at the beginning of the local area.
|
// Start at the beginning of the local area.
|
||||||
// The Offset is the distance from the stack top in the direction
|
// The Offset is the distance from the stack top in the direction
|
||||||
// of stack growth -- so it's always nonnegative.
|
// of stack growth -- so it's always nonnegative.
|
||||||
@ -517,9 +515,6 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
|
|||||||
Offset += FFI->getObjectSize(i);
|
Offset += FFI->getObjectSize(i);
|
||||||
|
|
||||||
unsigned Align = FFI->getObjectAlignment(i);
|
unsigned Align = FFI->getObjectAlignment(i);
|
||||||
// If the alignment of this object is greater than that of the stack,
|
|
||||||
// then increase the stack alignment to match.
|
|
||||||
MaxAlign = std::max(MaxAlign, Align);
|
|
||||||
// Adjust to alignment boundary
|
// Adjust to alignment boundary
|
||||||
Offset = (Offset+Align-1)/Align*Align;
|
Offset = (Offset+Align-1)/Align*Align;
|
||||||
|
|
||||||
@ -529,9 +524,6 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
|
|||||||
int MaxCSFI = MaxCSFrameIndex, MinCSFI = MinCSFrameIndex;
|
int MaxCSFI = MaxCSFrameIndex, MinCSFI = MinCSFrameIndex;
|
||||||
for (int i = MaxCSFI; i >= MinCSFI ; --i) {
|
for (int i = MaxCSFI; i >= MinCSFI ; --i) {
|
||||||
unsigned Align = FFI->getObjectAlignment(i);
|
unsigned Align = FFI->getObjectAlignment(i);
|
||||||
// If the alignment of this object is greater than that of the stack,
|
|
||||||
// then increase the stack alignment to match.
|
|
||||||
MaxAlign = std::max(MaxAlign, Align);
|
|
||||||
// Adjust to alignment boundary
|
// Adjust to alignment boundary
|
||||||
Offset = (Offset+Align-1)/Align*Align;
|
Offset = (Offset+Align-1)/Align*Align;
|
||||||
|
|
||||||
@ -540,6 +532,8 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned MaxAlign = FFI->getMaxAlignment();
|
||||||
|
|
||||||
// Make sure the special register scavenging spill slot is closest to the
|
// Make sure the special register scavenging spill slot is closest to the
|
||||||
// frame pointer if a frame pointer is required.
|
// frame pointer if a frame pointer is required.
|
||||||
const TargetRegisterInfo *RegInfo = Fn.getTarget().getRegisterInfo();
|
const TargetRegisterInfo *RegInfo = Fn.getTarget().getRegisterInfo();
|
||||||
@ -605,11 +599,6 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
|
|||||||
|
|
||||||
// Update frame info to pretend that this is part of the stack...
|
// Update frame info to pretend that this is part of the stack...
|
||||||
FFI->setStackSize(Offset - LocalAreaOffset);
|
FFI->setStackSize(Offset - LocalAreaOffset);
|
||||||
|
|
||||||
// Remember the required stack alignment in case targets need it to perform
|
|
||||||
// dynamic stack alignment.
|
|
||||||
if (MaxAlign > FFI->getMaxAlignment())
|
|
||||||
FFI->setMaxAlignment(MaxAlign);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -583,14 +583,6 @@ ARMBaseRegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
|||||||
SmallVector<unsigned, 4> UnspilledCS2GPRs;
|
SmallVector<unsigned, 4> UnspilledCS2GPRs;
|
||||||
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
||||||
|
|
||||||
|
|
||||||
// Calculate and set max stack object alignment early, so we can decide
|
|
||||||
// whether we will need stack realignment (and thus FP).
|
|
||||||
if (RealignStack) {
|
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
|
||||||
MFI->calculateMaxStackAlignment();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spill R4 if Thumb2 function requires stack realignment - it will be used as
|
// Spill R4 if Thumb2 function requires stack realignment - it will be used as
|
||||||
// scratch register.
|
// scratch register.
|
||||||
// FIXME: It will be better just to find spare register here.
|
// FIXME: It will be better just to find spare register here.
|
||||||
|
@ -485,7 +485,7 @@ X86RegisterInfo::getFrameIndexOffset(const MachineFunction &MF, int FI) const {
|
|||||||
Offset += SlotSize;
|
Offset += SlotSize;
|
||||||
} else {
|
} else {
|
||||||
unsigned Align = MFI->getObjectAlignment(FI);
|
unsigned Align = MFI->getObjectAlignment(FI);
|
||||||
assert( (-(Offset + StackSize)) % Align == 0);
|
assert((-(Offset + StackSize)) % Align == 0);
|
||||||
Align = 0;
|
Align = 0;
|
||||||
return Offset + StackSize;
|
return Offset + StackSize;
|
||||||
}
|
}
|
||||||
@ -627,10 +627,6 @@ X86RegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
|||||||
RegScavenger *RS) const {
|
RegScavenger *RS) const {
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
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).
|
|
||||||
MFI->calculateMaxStackAlignment();
|
|
||||||
|
|
||||||
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
||||||
int32_t TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
|
int32_t TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user