summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/PrologEpilogInserter.cpp
diff options
context:
space:
mode:
authorSander de Smalen <sander.desmalen@arm.com>2019-04-02 09:46:52 +0000
committerSander de Smalen <sander.desmalen@arm.com>2019-04-02 09:46:52 +0000
commit7f23e0a62fc95791af72d591d39f71b28642cc41 (patch)
tree69f763dc284c43c863f99c9e0396bbeb94729de1 /llvm/lib/CodeGen/PrologEpilogInserter.cpp
parentc5cefa2caf79af2f40555754cbb6ff6756053b12 (diff)
downloadbcm5719-llvm-7f23e0a62fc95791af72d591d39f71b28642cc41.tar.gz
bcm5719-llvm-7f23e0a62fc95791af72d591d39f71b28642cc41.zip
Enforce StackID definition in PEI
There are various places in LLVM where the definition of StackID is not properly honoured, for example in PEI where objects with a StackID > 0 are allocated on the default stack (StackID0). This patch enforces that PEI only considers allocating objects to StackID 0. Reviewers: arsenm, thegameg, MatzeB Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D60062 llvm-svn: 357460
Diffstat (limited to 'llvm/lib/CodeGen/PrologEpilogInserter.cpp')
-rw-r--r--llvm/lib/CodeGen/PrologEpilogInserter.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
index 920a915552a..67834c8c352 100644
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -661,10 +661,13 @@ computeFreeStackSlots(MachineFrameInfo &MFI, bool StackGrowsDown,
SmallVector<int, 16> AllocatedFrameSlots;
// Add fixed objects.
for (int i = MFI.getObjectIndexBegin(); i != 0; ++i)
- AllocatedFrameSlots.push_back(i);
+ // StackSlot scavenging is only implemented for the default stack.
+ if (MFI.getStackID(i) == 0)
+ AllocatedFrameSlots.push_back(i);
// Add callee-save objects.
for (int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
- AllocatedFrameSlots.push_back(i);
+ if (MFI.getStackID(i) == 0)
+ AllocatedFrameSlots.push_back(i);
for (int i : AllocatedFrameSlots) {
// These are converted from int64_t, but they should always fit in int
@@ -786,11 +789,21 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
// Skew to be applied to alignment.
unsigned Skew = TFI.getStackAlignmentSkew(MF);
+#ifdef EXPENSIVE_CHECKS
+ for (unsigned i = 0, e = MFI.getObjectIndexEnd(); i != e; ++i)
+ if (!MFI.isDeadObjectIndex(i) && MFI.getStackID(i) == 0)
+ assert(MFI.getObjectAlignment(i) <= MFI.getMaxAlignment() &&
+ "MaxAlignment is invalid");
+#endif
+
// If there are fixed sized objects that are preallocated in the local area,
// non-fixed objects can't be allocated right at the start of local area.
// Adjust 'Offset' to point to the end of last fixed sized preallocated
// object.
for (int i = MFI.getObjectIndexBegin(); i != 0; ++i) {
+ if (MFI.getStackID(i)) // Only allocate objects on the default stack.
+ continue;
+
int64_t FixedOff;
if (StackGrowsDown) {
// The maximum distance from the stack pointer is at lower address of
@@ -809,6 +822,9 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
// callee saved registers.
if (StackGrowsDown) {
for (unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
+ if (MFI.getStackID(i)) // Only allocate objects on the default stack.
+ continue;
+
// If the stack grows down, we need to add the size to find the lowest
// address of the object.
Offset += MFI.getObjectSize(i);
@@ -823,6 +839,9 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
} else if (MaxCSFrameIndex >= MinCSFrameIndex) {
// Be careful about underflow in comparisons agains MinCSFrameIndex.
for (unsigned i = MaxCSFrameIndex; i != MinCSFrameIndex - 1; --i) {
+ if (MFI.getStackID(i)) // Only allocate objects on the default stack.
+ continue;
+
if (MFI.isDeadObjectIndex(i))
continue;
@@ -913,6 +932,8 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
if (MFI.getStackProtectorIndex() == (int)i ||
EHRegNodeFrameIndex == (int)i)
continue;
+ if (MFI.getStackID(i)) // Only allocate objects on the default stack.
+ continue;
switch (MFI.getObjectSSPLayout(i)) {
case MachineFrameInfo::SSPLK_None:
@@ -956,6 +977,8 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
continue;
if (ProtectedObjs.count(i))
continue;
+ if (MFI.getStackID(i)) // Only allocate objects on the default stack.
+ continue;
// Add the objects that we need to allocate to our working set.
ObjectsToAllocate.push_back(i);
OpenPOWER on IntegriCloud