1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Temporarily revert r104655 as it's breaking the bots.

llvm-svn: 104664
This commit is contained in:
Eric Christopher 2010-05-26 01:59:55 +00:00
parent 95c228acb0
commit 13ac28ede3
3 changed files with 38 additions and 53 deletions

View File

@ -114,13 +114,9 @@ class MachineFunction {
/// ///
unsigned FunctionNumber; unsigned FunctionNumber;
/// Alignment - The alignment of the function. /// The alignment of the function.
unsigned Alignment; unsigned Alignment;
/// HasReturnsTwiceCall - Returns true if there's a call with a
/// "returns_twice" attribute, like setjmp.
bool HasReturnsTwiceCall;
MachineFunction(const MachineFunction &); // DO NOT IMPLEMENT MachineFunction(const MachineFunction &); // DO NOT IMPLEMENT
void operator=(const MachineFunction&); // DO NOT IMPLEMENT void operator=(const MachineFunction&); // DO NOT IMPLEMENT
public: public:
@ -185,15 +181,6 @@ public:
void EnsureAlignment(unsigned A) { void EnsureAlignment(unsigned A) {
if (Alignment < A) Alignment = A; if (Alignment < A) Alignment = A;
} }
/// hasReturnsTwiceCall - Returns true if there's a call with a
/// "returns_twice" attribute, like setjmp.
bool hasReturnsTwiceCall() const {
return HasReturnsTwiceCall;
}
void setReturnsTwiceCall(bool B) {
HasReturnsTwiceCall = B;
}
/// getInfo - Keep track of various per-function pieces of information for /// getInfo - Keep track of various per-function pieces of information for
/// backends that would like to do so. /// backends that would like to do so.

View File

@ -25,7 +25,6 @@
#include "llvm/Intrinsics.h" #include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h" #include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/CodeGen/FastISel.h" #include "llvm/CodeGen/FastISel.h"
#include "llvm/CodeGen/GCStrategy.h" #include "llvm/CodeGen/GCStrategy.h"
#include "llvm/CodeGen/GCMetadata.h" #include "llvm/CodeGen/GCMetadata.h"
@ -254,39 +253,6 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
done:; done:;
} }
// Set a flag indicating if the machine function makes a call to setjmp /
// sigsetjmp (i.e., a function marked "returns_twice"). We'll use this to
// disable certain optimizations which cannot handle such control flows.
//
// FIXME: This goes beyond the setjmp/sigsetjmp functions. We should check for
// the GCC "returns twice" attribute.
const Module *M = Fn.getParent();
const Function *SetJmp = M->getFunction("setjmp");
const Function *SigSetJmp = M->getFunction("sigsetjmp");
bool HasReturnsTwiceCall = false;
if (SetJmp || SigSetJmp) {
if (SetJmp && !SetJmp->use_empty())
for (Value::const_use_iterator
I = SetJmp->use_begin(), E = SetJmp->use_end(); I != E; ++I)
if (const CallInst *CI = dyn_cast<CallInst>(I))
if (CI->getParent()->getParent() == &Fn) {
HasReturnsTwiceCall = true;
break;
}
if (!HasReturnsTwiceCall && SigSetJmp && !SigSetJmp->use_empty())
for (Value::const_use_iterator
I = SigSetJmp->use_begin(), E = SigSetJmp->use_end(); I != E; ++I)
if (const CallInst *CI = dyn_cast<CallInst>(I))
if (CI->getParent()->getParent() == &Fn) {
HasReturnsTwiceCall = true;
break;
}
mf.setReturnsTwiceCall(HasReturnsTwiceCall);
}
// Release function-specific state. SDB and CurDAG are already cleared // Release function-specific state. SDB and CurDAG are already cleared
// at this point. // at this point.
FuncInfo->clear(); FuncInfo->clear();

View File

@ -118,6 +118,7 @@ namespace {
private: private:
void InitializeSlots(); void InitializeSlots();
bool CheckForSetJmpCall(const MachineFunction &MF) const;
void ScanForSpillSlotRefs(MachineFunction &MF); void ScanForSpillSlotRefs(MachineFunction &MF);
bool OverlapWithAssignments(LiveInterval *li, int Color) const; bool OverlapWithAssignments(LiveInterval *li, int Color) const;
int ColorSlot(LiveInterval *li); int ColorSlot(LiveInterval *li);
@ -161,6 +162,34 @@ namespace {
}; };
} }
/// CheckForSetJmpCall - Return true if there's a call to setjmp/sigsetjmp in
/// this function.
bool StackSlotColoring::CheckForSetJmpCall(const MachineFunction &MF) const {
const Function *F = MF.getFunction();
const Module *M = F->getParent();
const Function *SetJmp = M->getFunction("setjmp");
const Function *SigSetJmp = M->getFunction("sigsetjmp");
if (!SetJmp && !SigSetJmp)
return false;
if (SetJmp && !SetJmp->use_empty())
for (Value::const_use_iterator
I = SetJmp->use_begin(), E = SetJmp->use_end(); I != E; ++I)
if (const CallInst *CI = dyn_cast<CallInst>(I))
if (CI->getParent()->getParent() == F)
return true;
if (SigSetJmp && !SigSetJmp->use_empty())
for (Value::const_use_iterator
I = SigSetJmp->use_begin(), E = SigSetJmp->use_end(); I != E; ++I)
if (const CallInst *CI = dyn_cast<CallInst>(I))
if (CI->getParent()->getParent() == F)
return true;
return false;
}
/// ScanForSpillSlotRefs - Scan all the machine instructions for spill slot /// ScanForSpillSlotRefs - Scan all the machine instructions for spill slot
/// references and update spill slot weights. /// references and update spill slot weights.
void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) { void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) {
@ -724,11 +753,14 @@ bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) {
return false; return false;
} }
// If there is a call to a function with the attribute "returns_twice" (like // If there are calls to setjmp or sigsetjmp, don't perform stack slot
// setjmp or sigsetjmp), don't perform stack slot coloring. The stack could be // coloring. The stack could be modified before the longjmp is executed,
// modified before the the second return, resulting in the wrong value being // resulting in the wrong value being used afterwards. (See
// used afterwards. (See <rdar://problem/8007500>.) // <rdar://problem/8007500>.)
if (MF.hasReturnsTwiceCall()) //
// FIXME: This goes beyond the setjmp/sigsetjmp functions. Ideally, we should
// check for the GCC "returns twice" attribute.
if (CheckForSetJmpCall(MF))
return false; return false;
// Gather spill slot references // Gather spill slot references