mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Now that we have the ReturnsTwice function attribute, this method is
obsolete. Check the attribute instead. <rdar://problem/8031714> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142212 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f1fddcd9e0
commit
728662f9e8
@ -425,10 +425,6 @@ public:
|
|||||||
///
|
///
|
||||||
bool hasAddressTaken(const User** = 0) const;
|
bool hasAddressTaken(const User** = 0) const;
|
||||||
|
|
||||||
/// callsFunctionThatReturnsTwice - Return true if the function has a call to
|
|
||||||
/// setjmp or other function that gcc recognizes as "returning twice".
|
|
||||||
bool callsFunctionThatReturnsTwice() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Shadow Value::setValueSubclassData with a private forwarding method so that
|
// Shadow Value::setValueSubclassData with a private forwarding method so that
|
||||||
// subclasses cannot accidentally use it.
|
// subclasses cannot accidentally use it.
|
||||||
|
@ -225,12 +225,11 @@ unsigned CodeMetrics::CountCodeReductionForAlloca(Value *V) {
|
|||||||
/// analyzeFunction - Fill in the current structure with information gleaned
|
/// analyzeFunction - Fill in the current structure with information gleaned
|
||||||
/// from the specified function.
|
/// from the specified function.
|
||||||
void CodeMetrics::analyzeFunction(Function *F, const TargetData *TD) {
|
void CodeMetrics::analyzeFunction(Function *F, const TargetData *TD) {
|
||||||
// If this function contains a call to setjmp or _setjmp, never inline
|
// If this function contains a call that "returns twice" (e.g., setjmp or
|
||||||
// it. This is a hack because we depend on the user marking their local
|
// _setjmp), never inline it. This is a hack because we depend on the user
|
||||||
// variables as volatile if they are live across a setjmp call, and they
|
// marking their local variables as volatile if they are live across a setjmp
|
||||||
// probably won't do this in callers.
|
// call, and they probably won't do this in callers.
|
||||||
if (F->callsFunctionThatReturnsTwice())
|
callsSetJmp = F->hasFnAttr(Attribute::ReturnsTwice);
|
||||||
callsSetJmp = true;
|
|
||||||
|
|
||||||
// Look at the size of the callee.
|
// Look at the size of the callee.
|
||||||
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
|
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
|
||||||
|
@ -374,7 +374,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine if there is a call to setjmp in the machine function.
|
// Determine if there is a call to setjmp in the machine function.
|
||||||
MF->setCallsSetJmp(Fn.callsFunctionThatReturnsTwice());
|
MF->setCallsSetJmp(Fn.hasFnAttr(Attribute::ReturnsTwice));
|
||||||
|
|
||||||
// Replace forward-declared registers with the registers containing
|
// Replace forward-declared registers with the registers containing
|
||||||
// the desired value.
|
// the desired value.
|
||||||
|
@ -213,7 +213,7 @@ bool TailCallElim::runOnFunction(Function &F) {
|
|||||||
// Finally, if this function contains no non-escaping allocas, or calls
|
// Finally, if this function contains no non-escaping allocas, or calls
|
||||||
// setjmp, mark all calls in the function as eligible for tail calls
|
// setjmp, mark all calls in the function as eligible for tail calls
|
||||||
//(there is no stack memory for them to access).
|
//(there is no stack memory for them to access).
|
||||||
if (!FunctionContainsEscapingAllocas && !F.callsFunctionThatReturnsTwice())
|
if (!FunctionContainsEscapingAllocas && !F.hasFnAttr(Attribute::ReturnsTwice))
|
||||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
||||||
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
||||||
|
@ -411,44 +411,4 @@ bool Function::hasAddressTaken(const User* *PutOffender) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// callsFunctionThatReturnsTwice - Return true if the function has a call to
|
|
||||||
/// setjmp or other function that gcc recognizes as "returning twice".
|
|
||||||
///
|
|
||||||
/// FIXME: Remove after <rdar://problem/8031714> is fixed.
|
|
||||||
/// FIXME: Is the above FIXME valid?
|
|
||||||
bool Function::callsFunctionThatReturnsTwice() const {
|
|
||||||
static const char *const ReturnsTwiceFns[] = {
|
|
||||||
"_setjmp",
|
|
||||||
"setjmp",
|
|
||||||
"sigsetjmp",
|
|
||||||
"setjmp_syscall",
|
|
||||||
"savectx",
|
|
||||||
"qsetjmp",
|
|
||||||
"vfork",
|
|
||||||
"getcontext"
|
|
||||||
};
|
|
||||||
|
|
||||||
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())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// check for known function names.
|
|
||||||
// FIXME: move this to clang.
|
|
||||||
Function *F = callInst->getCalledFunction();
|
|
||||||
if (!F)
|
|
||||||
continue;
|
|
||||||
StringRef Name = F->getName();
|
|
||||||
for (unsigned J = 0, e = array_lengthof(ReturnsTwiceFns); J != e; ++J) {
|
|
||||||
if (Name == ReturnsTwiceFns[J])
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: sw=2 ai
|
// vim: sw=2 ai
|
||||||
|
Loading…
x
Reference in New Issue
Block a user