mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-04 02:24:29 +00:00
Simplify code a bit, and be sure to mark the external node as potentially throwing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12856 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -51,43 +51,43 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
|
|||||||
// obviously the SCC might throw.
|
// obviously the SCC might throw.
|
||||||
//
|
//
|
||||||
bool SCCMightThrow = false;
|
bool SCCMightThrow = false;
|
||||||
for (unsigned i = 0, e = SCC.size(); !SCCMightThrow && i != e; ++i)
|
for (unsigned i = 0, e = SCC.size(); !SCCMightThrow && i != e; ++i) {
|
||||||
if (Function *F = SCC[i]->getFunction())
|
Function *F = SCC[i]->getFunction();
|
||||||
if (F->isExternal() && !F->getIntrinsicID()) {
|
if (F == 0 || (F->isExternal() && !F->getIntrinsicID())) {
|
||||||
SCCMightThrow = true;
|
SCCMightThrow = true;
|
||||||
} else {
|
} else {
|
||||||
// Check to see if this function performs an unwind or calls an
|
// Check to see if this function performs an unwind or calls an
|
||||||
// unwinding function.
|
// unwinding function.
|
||||||
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
||||||
if (isa<UnwindInst>(BB->getTerminator())) { // Uses unwind!
|
if (isa<UnwindInst>(BB->getTerminator())) { // Uses unwind!
|
||||||
SCCMightThrow = true;
|
SCCMightThrow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke instructions don't allow unwinding to continue, so we are
|
// Invoke instructions don't allow unwinding to continue, so we are
|
||||||
// only interested in call instructions.
|
// only interested in call instructions.
|
||||||
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)) {
|
||||||
if (Function *Callee = CI->getCalledFunction()) {
|
if (Function *Callee = CI->getCalledFunction()) {
|
||||||
CallGraphNode *CalleeNode = CG[Callee];
|
CallGraphNode *CalleeNode = CG[Callee];
|
||||||
// If the callee is outside our current SCC, or if it is not
|
// If the callee is outside our current SCC, or if it is not
|
||||||
// known to throw, then we might throw also.
|
// known to throw, then we might throw also.
|
||||||
if (std::find(SCC.begin(), SCC.end(), CalleeNode) == SCC.end()&&
|
if (std::find(SCC.begin(), SCC.end(), CalleeNode) == SCC.end()&&
|
||||||
!DoesNotThrow.count(CalleeNode)) {
|
!DoesNotThrow.count(CalleeNode)) {
|
||||||
SCCMightThrow = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Indirect call, it might throw.
|
|
||||||
SCCMightThrow = true;
|
SCCMightThrow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Indirect call, it might throw.
|
||||||
|
SCCMightThrow = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (SCCMightThrow) break;
|
}
|
||||||
}
|
if (SCCMightThrow) break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
|
||||||
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
|
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
|
||||||
|
Reference in New Issue
Block a user