[WinEH] Fix funclet return block clobber mask placement
authorReid Kleckner <rnk@google.com>
Fri, 26 Feb 2016 16:53:19 +0000 (16:53 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 26 Feb 2016 16:53:19 +0000 (16:53 +0000)
commit70c9bc71d4f1a5cceea67ce6724da9080d5e05fa
tree2feb27c63b7e48dfe51de89981cabdb6df9d4270
parent68e15559b8c331a74f7b5a2a9b69b7b1d0d5bd48
[WinEH] Fix funclet return block clobber mask placement

MBB slot index intervals are half open, not closed. getMBBEndIndex()
returns the slot index of the start of the next block in layout order.
Placing a register mask there is incorrect if the successor of the
funclet return is not laid out after the return. Clang generates IR for
catch bodies before generating the following normal code, so we never
noticed this issue until the D frontend authors filed a bug about it.

Instead, we can put the clobber mask on the last instruction of the
funclet return block. We still aren't using a register mask operand on
the CATCHRET instruction because it would cause PEI to spill all CSRs,
including XMM regs, in the prologue.

Fixes PR26679.

llvm-svn: 262035
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/test/CodeGen/X86/catchret-regmask.ll [new file with mode: 0644]