summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/PrologEpilogInserter.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-03-01 04:30:16 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-03-01 04:30:16 +0000
commitcb305dea1cdd343510813ac813ecbfdac3906a80 (patch)
tree4ee4351f78c16cf862e36e9da010357606d922cc /llvm/lib/CodeGen/PrologEpilogInserter.cpp
parent04b4e10873f6728f382ce2e2aa71aa10831c101f (diff)
downloadbcm5719-llvm-cb305dea1cdd343510813ac813ecbfdac3906a80.tar.gz
bcm5719-llvm-cb305dea1cdd343510813ac813ecbfdac3906a80.zip
[WinEH] Allocate the registration node before the catch objects
The CatchObjOffset is relative to the end of the EH registration node for 32-bit x86 WinEH targets. A special sentinel value, 0, is used to indicate that no catch object should be initialized. This means that a catch object allocated immediately before the registration node would be assigned a CatchObjOffset of 0, leading the runtime to believe that a catch object should not be initialized. To handle this, allocate the registration node prior to any other frame object. This will ensure that catch objects will not be allocated before the registration node. This fixes PR26757. Differential Revision: http://reviews.llvm.org/D17689 llvm-svn: 262294
Diffstat (limited to 'llvm/lib/CodeGen/PrologEpilogInserter.cpp')
-rw-r--r--llvm/lib/CodeGen/PrologEpilogInserter.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
index 14a2d0800a5..96034ec0672 100644
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -709,6 +709,10 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
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) {
@@ -723,12 +727,20 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
continue;
if (MFI->getStackProtectorIndex() == (int)i)
continue;
+ if (EHRegNodeFrameIndex == (int)i)
+ continue;
if (ProtectedObjs.count(i))
continue;
// Add the objects that we need to allocate to our working set.
ObjectsToAllocate.push_back(i);
}
+
+ // Allocate the EH registration node first if one is present.
+ if (EHRegNodeFrameIndex != INT_MAX)
+ AdjustStackOffset(MFI, EHRegNodeFrameIndex, StackGrowsDown, Offset,
+ MaxAlign, Skew);
+
// Give the targets a chance to order the objects the way they like it.
if (Fn.getTarget().getOptLevel() != CodeGenOpt::None &&
Fn.getTarget().Options.StackSymbolOrdering)
OpenPOWER on IntegriCloud