[llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Feb 3 17:12:03 PST 2004


Changes in directory llvm/lib/VMCore:

BasicBlock.cpp updated: 1.38 -> 1.39

---
Log message:

In BasicBlock::splitBasicBlock, just use islist::splice to move the instructions, 
instead of a loop that is really inefficient with large basic blocks.

This speeds up the inliner pass on the testcase in PR209 from 13.8s to 2.24s
which still isn't exactly speedy, but is a lot better.  :)



---
Diffs of the changes:  (+3 -8)

Index: llvm/lib/VMCore/BasicBlock.cpp
diff -u llvm/lib/VMCore/BasicBlock.cpp:1.38 llvm/lib/VMCore/BasicBlock.cpp:1.39
--- llvm/lib/VMCore/BasicBlock.cpp:1.38	Fri Nov 21 10:52:05 2003
+++ llvm/lib/VMCore/BasicBlock.cpp	Tue Feb  3 17:11:21 2004
@@ -233,14 +233,9 @@
 
   BasicBlock *New = new BasicBlock(BBName, getParent());
 
-  // Go from the end of the basic block through to the iterator pointer, moving
-  // to the new basic block...
-  Instruction *Inst = 0;
-  do {
-    iterator EndIt = end();
-    Inst = InstList.remove(--EndIt);                  // Remove from end
-    New->InstList.push_front(Inst);                   // Add to front
-  } while (Inst != &*I);   // Loop until we move the specified instruction.
+  // Move all of the specified instructions from the original basic block into
+  // the new basic block.
+  New->getInstList().splice(New->end(), this->getInstList(), I, end());
 
   // Add a branch instruction to the newly formed basic block.
   new BranchInst(New, this);





More information about the llvm-commits mailing list