diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2014-01-14 04:20:01 +0000 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2014-01-14 04:20:01 +0000 |
commit | dfa550a1761a85417d0e42c8cd17cd08e753388b (patch) | |
tree | a62e58f745ddc64b711e049878ce80eda82cce48 /lib | |
parent | 3f7ae00155439d44391531389629f3a7a8378fca (diff) | |
download | llvm-dfa550a1761a85417d0e42c8cd17cd08e753388b.tar.gz llvm-dfa550a1761a85417d0e42c8cd17cd08e753388b.tar.bz2 llvm-dfa550a1761a85417d0e42c8cd17cd08e753388b.tar.xz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IR/Function.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index 970bbaeed8..bb6bef7bd0 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -736,10 +736,8 @@ bool Function::isDefTriviallyDead() const { bool Function::callsFunctionThatReturnsTwice() const { for (const_inst_iterator I = inst_begin(this), E = inst_end(this); I != E; ++I) { - const CallInst* callInst = dyn_cast<CallInst>(&*I); - if (!callInst) - continue; - if (callInst->canReturnTwice()) + ImmutableCallSite CS(&*I); + if (CS && CS.hasFnAttr(Attribute::ReturnsTwice)) return true; } |