summaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineFrameInfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/CodeGen/MachineFrameInfo.h')
-rw-r--r--include/llvm/CodeGen/MachineFrameInfo.h72
1 files changed, 55 insertions, 17 deletions
diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h
index 689f3cd9fd12b..f887517217e18 100644
--- a/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/include/llvm/CodeGen/MachineFrameInfo.h
@@ -31,15 +31,30 @@ class AllocaInst;
class CalleeSavedInfo {
unsigned Reg;
int FrameIdx;
+ /// Flag indicating whether the register is actually restored in the epilog.
+ /// In most cases, if a register is saved, it is also restored. There are
+ /// some situations, though, when this is not the case. For example, the
+ /// LR register on ARM is usually saved, but on exit from the function its
+ /// saved value may be loaded directly into PC. Since liveness tracking of
+ /// physical registers treats callee-saved registers are live outside of
+ /// the function, LR would be treated as live-on-exit, even though in these
+ /// scenarios it is not. This flag is added to indicate that the saved
+ /// register described by this object is not restored in the epilog.
+ /// The long-term solution is to model the liveness of callee-saved registers
+ /// by implicit uses on the return instructions, however, the required
+ /// changes in the ARM backend would be quite extensive.
+ bool Restored;
public:
explicit CalleeSavedInfo(unsigned R, int FI = 0)
- : Reg(R), FrameIdx(FI) {}
+ : Reg(R), FrameIdx(FI), Restored(true) {}
// Accessors.
unsigned getReg() const { return Reg; }
int getFrameIdx() const { return FrameIdx; }
void setFrameIdx(int FI) { FrameIdx = FI; }
+ bool isRestored() const { return Restored; }
+ void setRestored(bool R) { Restored = R; }
};
/// The MachineFrameInfo class represents an abstract stack frame until
@@ -99,8 +114,16 @@ class MachineFrameInfo {
/// and/or GC related) over a statepoint. We know that the address of the
/// slot can't alias any LLVM IR value. This is very similar to a Spill
/// Slot, but is created by statepoint lowering is SelectionDAG, not the
- /// register allocator.
- bool isStatepointSpillSlot;
+ /// register allocator.
+ bool isStatepointSpillSlot = false;
+
+ /// Identifier for stack memory type analagous to address space. If this is
+ /// non-0, the meaning is target defined. Offsets cannot be directly
+ /// compared between objects with different stack IDs. The object may not
+ /// necessarily reside in the same contiguous memory block as other stack
+ /// objects. Objects with differing stack IDs should not be merged or
+ /// replaced substituted for each other.
+ uint8_t StackID;
/// If this stack object is originated from an Alloca instruction
/// this value saves the original IR allocation. Can be NULL.
@@ -108,7 +131,7 @@ class MachineFrameInfo {
// If true, the object was mapped into the local frame
// block and doesn't need additional handling for allocation beyond that.
- bool PreAllocated;
+ bool PreAllocated = false;
// If true, an LLVM IR value might point to this object.
// Normally, spill slots and fixed-offset objects don't alias IR-accessible
@@ -117,16 +140,17 @@ class MachineFrameInfo {
bool isAliased;
/// If true, the object has been zero-extended.
- bool isZExt;
+ bool isZExt = false;
/// If true, the object has been zero-extended.
- bool isSExt;
+ bool isSExt = false;
- StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM,
- bool isSS, const AllocaInst *Val, bool A)
- : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM),
- isSpillSlot(isSS), isStatepointSpillSlot(false), Alloca(Val),
- PreAllocated(false), isAliased(A), isZExt(false), isSExt(false) {}
+ StackObject(uint64_t Size, unsigned Alignment, int64_t SPOffset,
+ bool IsImmutable, bool IsSpillSlot, const AllocaInst *Alloca,
+ bool IsAliased, uint8_t StackID = 0)
+ : SPOffset(SPOffset), Size(Size), Alignment(Alignment),
+ isImmutable(IsImmutable), isSpillSlot(IsSpillSlot),
+ StackID(StackID), Alloca(Alloca), isAliased(IsAliased) {}
};
/// The alignment of the stack.
@@ -549,13 +573,13 @@ public:
/// All fixed objects should be created before other objects are created for
/// efficiency. By default, fixed objects are not pointed to by LLVM IR
/// values. This returns an index with a negative value.
- int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable,
+ int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable,
bool isAliased = false);
/// Create a spill slot at a fixed location on the stack.
/// Returns an index with a negative value.
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset,
- bool Immutable = false);
+ bool IsImmutable = false);
/// Returns true if the specified index corresponds to a fixed stack object.
bool isFixedObjectIndex(int ObjectIdx) const {
@@ -581,10 +605,10 @@ public:
}
/// Marks the immutability of an object.
- void setIsImmutableObjectIndex(int ObjectIdx, bool Immutable) {
+ void setIsImmutableObjectIndex(int ObjectIdx, bool IsImmutable) {
assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
"Invalid Object Idx!");
- Objects[ObjectIdx+NumFixedObjects].isImmutable = Immutable;
+ Objects[ObjectIdx+NumFixedObjects].isImmutable = IsImmutable;
}
/// Returns true if the specified index corresponds to a spill slot.
@@ -600,6 +624,18 @@ public:
return Objects[ObjectIdx+NumFixedObjects].isStatepointSpillSlot;
}
+ /// \see StackID
+ uint8_t getStackID(int ObjectIdx) const {
+ return Objects[ObjectIdx+NumFixedObjects].StackID;
+ }
+
+ /// \see StackID
+ void setStackID(int ObjectIdx, uint8_t ID) {
+ assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+ "Invalid Object Idx!");
+ Objects[ObjectIdx+NumFixedObjects].StackID = ID;
+ }
+
/// Returns true if the specified index corresponds to a dead object.
bool isDeadObjectIndex(int ObjectIdx) const {
assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
@@ -624,8 +660,8 @@ public:
/// Create a new statically sized stack object, returning
/// a nonnegative identifier to represent it.
- int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS,
- const AllocaInst *Alloca = nullptr);
+ int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot,
+ const AllocaInst *Alloca = nullptr, uint8_t ID = 0);
/// Create a new statically sized stack object that represents a spill slot,
/// returning a nonnegative identifier to represent it.
@@ -646,6 +682,8 @@ public:
const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {
return CSInfo;
}
+ /// \copydoc getCalleeSavedInfo()
+ std::vector<CalleeSavedInfo> &getCalleeSavedInfo() { return CSInfo; }
/// Used by prolog/epilog inserter to set the function's callee saved
/// information.