diff options
author | Bill Wendling <isanbard@gmail.com> | 2010-07-27 01:55:19 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2010-07-27 01:55:19 +0000 |
commit | dfc2c51d12fd53822279b6e564cdd5cef5c00b46 (patch) | |
tree | 28551e2f1fe74455cafc88e6513619690134d9d1 /include/llvm/CodeGen/MachineFrameInfo.h | |
parent | ab28928fe276d20cf9533ae6b858497f835c7a53 (diff) |
It's better to have the arrays, which would trigger the creation of stack
protectors, to be near the stack protectors on the stack. Accomplish this by
tagging the stack object with a predicate that indicates that it would trigger
this. In the prolog-epilog inserter, assign these objects to the stack after the
stack protector but before the other objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109481 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineFrameInfo.h')
-rw-r--r-- | include/llvm/CodeGen/MachineFrameInfo.h | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index 57f3b6a0a9..03ff6af3cc 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -94,13 +94,19 @@ class MachineFrameInfo { // default, fixed objects are immutable unless marked otherwise. bool isImmutable; - // isSpillSlot - If true, the stack object is used as spill slot. It + // isSpillSlot - If true the stack object is used as spill slot. It // cannot alias any other memory objects. bool isSpillSlot; - StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, bool isSS) + // MayNeedSP - If true the stack object triggered the creation of the stack + // protector. We should allocate this object right after the stack + // protector. + bool MayNeedSP; + + StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, + bool isSS, bool NSP) : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), - isSpillSlot(isSS) {} + isSpillSlot(isSS), MayNeedSP(NSP) {} }; /// Objects - The list of stack objects allocated... @@ -276,6 +282,14 @@ public: MaxAlignment = std::max(MaxAlignment, Align); } + /// NeedsStackProtector - Returns true if the object may need stack + /// protectors. + bool MayNeedStackProtector(int ObjectIdx) const { + assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && + "Invalid Object Idx!"); + return Objects[ObjectIdx+NumFixedObjects].MayNeedSP; + } + /// getObjectOffset - Return the assigned stack offset of the specified object /// from the incoming stack pointer. /// @@ -382,25 +396,26 @@ public: return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL; } - /// CreateStackObject - Create a new statically sized stack object, - /// returning a nonnegative identifier to represent it. + /// CreateStackObject - Create a new statically sized stack object, returning + /// a nonnegative identifier to represent it. /// - int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS) { + int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, + bool MayNeedSP = false) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); - Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); - int Index = (int)Objects.size()-NumFixedObjects-1; + 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); return Index; } - /// CreateSpillStackObject - Create a new statically sized stack - /// object that represents a spill slot, returning a nonnegative - /// identifier to represent it. + /// CreateSpillStackObject - Create a new statically sized stack object that + /// represents a spill slot, returning a nonnegative identifier to represent + /// it. /// int CreateSpillStackObject(uint64_t Size, unsigned Alignment) { - CreateStackObject(Size, Alignment, true); - int Index = (int)Objects.size()-NumFixedObjects-1; + CreateStackObject(Size, Alignment, true, false); + int Index = (int)Objects.size() - NumFixedObjects - 1; MaxAlignment = std::max(MaxAlignment, Alignment); return Index; } @@ -419,7 +434,7 @@ public: /// int CreateVariableSizedObject(unsigned Alignment) { HasVarSizedObjects = true; - Objects.push_back(StackObject(0, Alignment, 0, false, false)); + Objects.push_back(StackObject(0, Alignment, 0, false, false, true)); MaxAlignment = std::max(MaxAlignment, Alignment); return (int)Objects.size()-NumFixedObjects-1; } |