summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/PruneEH.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-12 04:06:38 +0000
committerChris Lattner <sabre@nondot.org>2004-04-12 04:06:38 +0000
commitd08ddd3300d5244012c1765d34b21cc9e11a80ad (patch)
tree1df8cdf138b0a41c0bc87d4b2c991df7c3ce421f /lib/Transforms/IPO/PruneEH.cpp
parent133dbb128501f7006a533678261dd8e0debc663c (diff)
downloadllvm-d08ddd3300d5244012c1765d34b21cc9e11a80ad.tar.gz
llvm-d08ddd3300d5244012c1765d34b21cc9e11a80ad.tar.bz2
llvm-d08ddd3300d5244012c1765d34b21cc9e11a80ad.tar.xz
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
Diffstat (limited to 'lib/Transforms/IPO/PruneEH.cpp')
-rw-r--r--lib/Transforms/IPO/PruneEH.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp
index cbe4159601..418c3528d3 100644
--- a/lib/Transforms/IPO/PruneEH.cpp
+++ b/lib/Transforms/IPO/PruneEH.cpp
@@ -51,43 +51,43 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
// obviously the SCC might throw.
//
bool SCCMightThrow = false;
- for (unsigned i = 0, e = SCC.size(); !SCCMightThrow && i != e; ++i)
- if (Function *F = SCC[i]->getFunction())
- if (F->isExternal() && !F->getIntrinsicID()) {
- SCCMightThrow = true;
- } else {
- // Check to see if this function performs an unwind or calls an
- // unwinding function.
- for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
- if (isa<UnwindInst>(BB->getTerminator())) { // Uses unwind!
- SCCMightThrow = true;
- break;
- }
+ for (unsigned i = 0, e = SCC.size(); !SCCMightThrow && i != e; ++i) {
+ Function *F = SCC[i]->getFunction();
+ if (F == 0 || (F->isExternal() && !F->getIntrinsicID())) {
+ SCCMightThrow = true;
+ } else {
+ // Check to see if this function performs an unwind or calls an
+ // unwinding function.
+ for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
+ if (isa<UnwindInst>(BB->getTerminator())) { // Uses unwind!
+ SCCMightThrow = true;
+ break;
+ }
- // Invoke instructions don't allow unwinding to continue, so we are
- // only interested in call instructions.
- for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
- if (CallInst *CI = dyn_cast<CallInst>(I)) {
- if (Function *Callee = CI->getCalledFunction()) {
- CallGraphNode *CalleeNode = CG[Callee];
- // If the callee is outside our current SCC, or if it is not
- // known to throw, then we might throw also.
- if (std::find(SCC.begin(), SCC.end(), CalleeNode) == SCC.end()&&
- !DoesNotThrow.count(CalleeNode)) {
- SCCMightThrow = true;
- break;
- }
-
- } else {
- // Indirect call, it might throw.
+ // Invoke instructions don't allow unwinding to continue, so we are
+ // only interested in call instructions.
+ for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+ if (CallInst *CI = dyn_cast<CallInst>(I)) {
+ if (Function *Callee = CI->getCalledFunction()) {
+ CallGraphNode *CalleeNode = CG[Callee];
+ // If the callee is outside our current SCC, or if it is not
+ // known to throw, then we might throw also.
+ if (std::find(SCC.begin(), SCC.end(), CalleeNode) == SCC.end()&&
+ !DoesNotThrow.count(CalleeNode)) {
SCCMightThrow = true;
break;
}
+
+ } else {
+ // Indirect call, it might throw.
+ SCCMightThrow = true;
+ break;
}
- if (SCCMightThrow) break;
- }
+ }
+ if (SCCMightThrow) break;
}
-
+ }
+ }
bool MadeChange = false;
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {