Reserve space in vectors before topologically sorting into them. This improves the...
authorOwen Anderson <resistor@mac.com>
Fri, 22 Jun 2007 00:43:22 +0000 (00:43 +0000)
committerOwen Anderson <resistor@mac.com>
Fri, 22 Jun 2007 00:43:22 +0000 (00:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37699 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVNPRE.cpp

index 078d89548479da0243449aedab8b026baff4d8fc..045ca5c4f822fcd81b7af4eafc61960f2b30c546 100644 (file)
@@ -585,6 +585,7 @@ bool GVNPRE::dependsOnInvoke(Value* V) {
 /// above)
 void GVNPRE::clean(SmallPtrSet<Value*, 32>& set) {
   std::vector<Value*> worklist;
+  worklist.reserve(set.size());
   topo_sort(set, worklist);
   
   for (unsigned i = 0; i < worklist.size(); ++i) {
@@ -1173,6 +1174,7 @@ bool GVNPRE::insertion(Function& F) {
       // If there is more than one predecessor...
       if (pred_begin(BB) != pred_end(BB) && ++pred_begin(BB) != pred_end(BB)) {
         std::vector<Value*> workList;
+        workList.reserve(anticIn.size());
         topo_sort(anticIn, workList);
         
         DOUT << "Merge Block: " << BB->getName() << "\n";