From dfa550a1761a85417d0e42c8cd17cd08e753388b Mon Sep 17 00:00:00 2001 From: Mark Seaborn Date: Tue, 14 Jan 2014 04:20:01 +0000 Subject: 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 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') 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(&*I); - if (!callInst) - continue; - if (callInst->canReturnTwice()) + ImmutableCallSite CS(&*I); + if (CS && CS.hasFnAttr(Attribute::ReturnsTwice)) return true; } -- cgit v1.2.3