[CodeGen] Don't scavenge non-saved regs in exception throwing functions
authorOliver Stannard <oliver.stannard@arm.com>
Fri, 1 Feb 2019 09:23:51 +0000 (09:23 +0000)
committerOliver Stannard <oliver.stannard@arm.com>
Fri, 1 Feb 2019 09:23:51 +0000 (09:23 +0000)
commitbac11518cd44f85cea38e5be116388cd254de9eb
treedb0b9e5b18b73181d226f571019b39e84c1608ab
parent3440c33989eddfbc4868ad7e302e6418faf53c81
[CodeGen] Don't scavenge non-saved regs in exception throwing functions

Previously, LiveRegUnits was assuming that if a block has no successors
and does not return, then no registers are live at the end of it
(because the end of the block is unreachable). This was causing the
register scavenger to use callee-saved registers to materialise stack
frame addresses without saving them in the prologue. This would normally
be fine, because the end of the block is unreachable, but this is not
legal if the block ends by throwing a C++ exception. If this happens,
the scratch register will be modified, but its previous value won't be
preserved, so it doesn't get restored by the exception unwinder.

Differential revision: https://reviews.llvm.org/D57381

llvm-svn: 352844
llvm/lib/CodeGen/LiveRegUnits.cpp
llvm/test/CodeGen/ARM/register-scavenger-exceptions.mir [new file with mode: 0644]