Skip to content

Commit 2888cc7

Browse files
Merge pull request #6782 from aschwaighofer/lto_alloc_stack_hoisting_workaround
Hack to workaround a clang lto bug
2 parents f88ef97 + d6dd8e8 commit 2888cc7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/IRGen/AllocStackHoisting.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ insertDeallocStackAtEndOf(SmallVectorImpl<SILInstruction *> &FunctionExits,
110110
}
111111
}
112112

113+
/// Hack to workaround a clang LTO bug.
114+
__attribute__((noinline))
115+
void moveAllocStackToBeginningOfBlock(AllocStackInst* AS, SILBasicBlock *BB) {
116+
AS->removeFromParent();
117+
BB->push_front(AS);
118+
}
119+
113120
/// Assign a single alloc_stack instruction to all the alloc_stacks in the
114121
/// partition.
115122
void Partition::assignStackLocation(
@@ -120,8 +127,7 @@ void Partition::assignStackLocation(
120127

121128
// Move this assigned location to the beginning of the entry block.
122129
auto *EntryBB = AssignedLoc->getFunction()->getEntryBlock();
123-
AssignedLoc->removeFromParent();
124-
EntryBB->push_front(AssignedLoc);
130+
moveAllocStackToBeginningOfBlock(AssignedLoc, EntryBB);
125131

126132
// Erase the dealloc_stacks.
127133
eraseDeallocStacks(AssignedLoc);

0 commit comments

Comments
 (0)