From bc9fa589efdfba8c86a8dee4f8e92b79025a7419 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 26 Apr 2005 23:53:25 +0000 Subject: [PATCH] This analysis doesn't take 'throwing' into consideration, it looks at 'unwinding' git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21581 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/PruneEH.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 381722e48c5..a31a3343e34 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -29,9 +29,9 @@ namespace { Statistic<> NumRemoved("prune-eh", "Number of invokes removed"); struct PruneEH : public CallGraphSCCPass { - /// DoesNotThrow - This set contains all of the functions which we have + /// DoesNotUnwind - This set contains all of the functions which we have /// determined cannot throw exceptions. - std::set DoesNotThrow; + std::set DoesNotUnwind; // runOnSCC - Analyze the SCC, performing the transformation if possible. bool runOnSCC(const std::vector &SCC); @@ -50,17 +50,17 @@ bool PruneEH::runOnSCC(const std::vector &SCC) { // If this SCC includes the unwind instruction, we KNOW it throws, so // obviously the SCC might throw. // - bool SCCMightThrow = false; - for (unsigned i = 0, e = SCC.size(); !SCCMightThrow && i != e; ++i) { + bool SCCMightUnwind = false; + for (unsigned i = 0, e = SCC.size(); !SCCMightUnwind && i != e; ++i) { Function *F = SCC[i]->getFunction(); if (F == 0 || (F->isExternal() && !F->getIntrinsicID())) { - SCCMightThrow = true; + SCCMightUnwind = 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(BB->getTerminator())) { // Uses unwind! - SCCMightThrow = true; + SCCMightUnwind = true; break; } @@ -73,18 +73,18 @@ bool PruneEH::runOnSCC(const std::vector &SCC) { // 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; + !DoesNotUnwind.count(CalleeNode)) { + SCCMightUnwind = true; break; } } else { // Indirect call, it might throw. - SCCMightThrow = true; + SCCMightUnwind = true; break; } } - if (SCCMightThrow) break; + if (SCCMightUnwind) break; } } } @@ -92,8 +92,8 @@ bool PruneEH::runOnSCC(const std::vector &SCC) { for (unsigned i = 0, e = SCC.size(); i != e; ++i) { // If the SCC can't throw, remember this for callers... - if (!SCCMightThrow) - DoesNotThrow.insert(SCC[i]); + if (!SCCMightUnwind) + DoesNotUnwind.insert(SCC[i]); // Convert any invoke instructions to non-throwing functions in this node // into call instructions with a branch. This makes the exception blocks @@ -102,7 +102,7 @@ bool PruneEH::runOnSCC(const std::vector &SCC) { for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) if (InvokeInst *II = dyn_cast(I->getTerminator())) if (Function *F = II->getCalledFunction()) - if (DoesNotThrow.count(CG[F])) { + if (DoesNotUnwind.count(CG[F])) { // Insert a call instruction before the invoke... std::string Name = II->getName(); II->setName(""); Value *Call = new CallInst(II->getCalledValue(),