[llvm-commits] [llvm] r137099 - /llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp

Bill Wendling isanbard at gmail.com
Mon Aug 8 18:17:10 PDT 2011


Author: void
Date: Mon Aug  8 20:17:10 2011
New Revision: 137099

URL: http://llvm.org/viewvc/llvm-project?rev=137099&view=rev
Log:
There is only one instance of this placeholder being created. Just use that
instead of a vector.

Modified:
    llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp

Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=137099&r1=137098&r2=137099&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Mon Aug  8 20:17:10 2011
@@ -406,7 +406,7 @@
   SmallVector<ReturnInst*,16> Returns;
   SmallVector<UnwindInst*,16> Unwinds;
   SmallVector<InvokeInst*,16> Invokes;
-  SmallVector<UnreachableInst*, 16> Unreachables;
+  UnreachableInst* UnreachablePlaceholder = 0;
 
   for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
     if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
@@ -490,7 +490,7 @@
     // for a standard call). We insert an unreachable instruction here and
     // modify the block to jump to the correct unwinding pad later.
     BasicBlock *UnwindBB = BasicBlock::Create(F.getContext(), "unwindbb", &F);
-    Unreachables.push_back(new UnreachableInst(F.getContext(), UnwindBB));
+    UnreachablePlaceholder = new UnreachableInst(F.getContext(), UnwindBB);
 
     Value *CatchLoad = new LoadInst(InvokeNum, "invoke.num", true, CatchBB);
     SwitchInst *CatchSwitch =
@@ -579,10 +579,10 @@
     Unwinds[i]->eraseFromParent();
   }
 
-  // Replace all inserted unreachables with a branch to the unwind handler.
-  for (unsigned i = 0, e = Unreachables.size(); i != e; ++i) {
-    BranchInst::Create(UnwindHandler, Unreachables[i]);
-    Unreachables[i]->eraseFromParent();
+  // Replace the inserted unreachable with a branch to the unwind handler.
+  if (UnreachablePlaceholder) {
+    BranchInst::Create(UnwindHandler, UnreachablePlaceholder);
+    UnreachablePlaceholder->eraseFromParent();
   }
 
   // Finally, for any returns from this function, if this function contains an





More information about the llvm-commits mailing list