Fix llc to not reuse spill slots in functions that invoke setjmp()
authorMark Seaborn <mseaborn@chromium.org>
Tue, 14 Jan 2014 04:20:01 +0000 (04:20 +0000)
committerMark Seaborn <mseaborn@chromium.org>
Tue, 14 Jan 2014 04:20:01 +0000 (04:20 +0000)
commitdfa550a1761a85417d0e42c8cd17cd08e753388b
treea62e58f745ddc64b711e049878ce80eda82cce48
parent3f7ae00155439d44391531389629f3a7a8378fca
Fix llc to not reuse spill slots in functions that invoke setjmp()

We need to ensure that StackSlotColoring.cpp does not reuse stack
spill slots in functions that call "returns_twice" functions such as
setjmp(), otherwise this can lead to miscompiled code, because a stack
slot would be clobbered when it's still live.

This was already handled correctly for functions that call setjmp()
(though this wasn't covered by a test), but not for functions that
invoke setjmp().

We fix this by changing callsFunctionThatReturnsTwice() to check for
invoke instructions.

This fixes PR18244.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199180 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/Function.cpp
test/CodeGen/X86/setjmp-spills.ll [new file with mode: 0644]