[llvm] r272426 - [CodeGen] Fix PrologEpilogInserter to avoid duplicate allocation of SEH structs
Etienne Bergeron via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 10 13:24:38 PDT 2016
Author: etienneb
Date: Fri Jun 10 15:24:38 2016
New Revision: 272426
URL: http://llvm.org/viewvc/llvm-project?rev=272426&view=rev
Log:
[CodeGen] Fix PrologEpilogInserter to avoid duplicate allocation of SEH structs
Summary:
When stack-protection is activated and WinEH exceptions is used,
the EHRegNode (exception handling registration) is allocated twice on the stack.
This was not breaking anything except loosing space on the stack.
```
D:\src\llvm\examples>llc exc2.ll -debug-only=pei
alloc FI(0) at SP[-24]
alloc FI(1) at SP[-48] <<-- Allocated
alloc FI(1) at SP[-72] <<-- Allocated twice!?
alloc FI(2) at SP[-76]
alloc FI(4) at SP[-80]
alloc FI(3) at SP[-84]
```
Reviewers: rnk, majnemer
Subscribers: chrisha, llvm-commits
Differential Revision: http://reviews.llvm.org/D21188
Modified:
llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=272426&r1=272425&r2=272426&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
+++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Fri Jun 10 15:24:38 2016
@@ -815,6 +815,11 @@ void PEI::calculateFrameObjectOffsets(Ma
MaxAlign = std::max(Align, MaxAlign);
}
+ // Retrieve the Exception Handler registration node.
+ int EHRegNodeFrameIndex = INT_MAX;
+ if (const WinEHFuncInfo *FuncInfo = Fn.getWinEHFuncInfo())
+ EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
+
// Make sure that the stack protector comes before the local variables on the
// stack.
SmallSet<int, 16> ProtectedObjs;
@@ -837,7 +842,8 @@ void PEI::calculateFrameObjectOffsets(Ma
continue;
if (MFI->isDeadObjectIndex(i))
continue;
- if (MFI->getStackProtectorIndex() == (int)i)
+ if (MFI->getStackProtectorIndex() == (int)i ||
+ EHRegNodeFrameIndex == (int)i)
continue;
switch (SP->getSSPLayout(MFI->getObjectAllocation(i))) {
@@ -866,10 +872,6 @@ void PEI::calculateFrameObjectOffsets(Ma
SmallVector<int, 8> ObjectsToAllocate;
- int EHRegNodeFrameIndex = INT_MAX;
- if (const WinEHFuncInfo *FuncInfo = Fn.getWinEHFuncInfo())
- EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
-
// Then prepare to assign frame offsets to stack objects that are not used to
// spill callee saved registers.
for (unsigned i = 0, e = MFI->getObjectIndexEnd(); i != e; ++i) {
@@ -882,9 +884,8 @@ void PEI::calculateFrameObjectOffsets(Ma
continue;
if (MFI->isDeadObjectIndex(i))
continue;
- if (MFI->getStackProtectorIndex() == (int)i)
- continue;
- if (EHRegNodeFrameIndex == (int)i)
+ if (MFI->getStackProtectorIndex() == (int)i ||
+ EHRegNodeFrameIndex == (int)i)
continue;
if (ProtectedObjs.count(i))
continue;
More information about the llvm-commits
mailing list