[WinEH] Allocate the registration node before the catch objects
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 1 Mar 2016 04:30:16 +0000 (04:30 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 1 Mar 2016 04:30:16 +0000 (04:30 +0000)
commitcb305dea1cdd343510813ac813ecbfdac3906a80
tree4ee4351f78c16cf862e36e9da010357606d922cc
parent04b4e10873f6728f382ce2e2aa71aa10831c101f
[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
llvm/lib/CodeGen/AsmPrinter/WinException.cpp
llvm/lib/CodeGen/PrologEpilogInserter.cpp
llvm/test/CodeGen/X86/cleanuppad-inalloca.ll
llvm/test/CodeGen/X86/pr26757.ll [new file with mode: 0644]