aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2014-01-14 04:20:01 +0000
committerMark Seaborn <mseaborn@chromium.org>2014-01-14 04:20:01 +0000
commit8271118a65ffb8216593967df504fae2c9252bd2 (patch)
tree74b575b8159fa24ddad2894070dd41962a5d30fd /llvm/lib/IR/Function.cpp
parentaf968eda27a3574e89aa7920ad84b2085293f4b5 (diff)
downloadllvm-8271118a65ffb8216593967df504fae2c9252bd2.zip
llvm-8271118a65ffb8216593967df504fae2c9252bd2.tar.gz
llvm-8271118a65ffb8216593967df504fae2c9252bd2.tar.bz2
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. llvm-svn: 199180
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 970bbae..bb6bef7 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/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;
}