@@ -28,7 +28,7 @@ Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
2828 if (InsertBefore) {
2929 BasicBlock *BB = InsertBefore->getParent ();
3030 assert (BB && " Instruction to insert before is not in a basic block!" );
31- BB-> getInstList (). insert ( InsertBefore->getIterator (), this );
31+ insertAt (BB, InsertBefore->getIterator ());
3232 }
3333}
3434
@@ -38,7 +38,7 @@ Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
3838
3939 // append this instruction into the basic block
4040 assert (InsertAtEnd && " Basic block to append to may not be NULL!" );
41- InsertAtEnd-> getInstList (). push_back ( this );
41+ insertAt ( InsertAtEnd, InsertAtEnd-> end () );
4242}
4343
4444Instruction::~Instruction () {
@@ -85,14 +85,13 @@ iplist<Instruction>::iterator Instruction::eraseFromParent() {
8585// / Insert an unlinked instruction into a basic block immediately before the
8686// / specified instruction.
8787void Instruction::insertBefore (Instruction *InsertPos) {
88- InsertPos->getParent ()-> getInstList (). insert ( InsertPos->getIterator (), this );
88+ insertAt ( InsertPos->getParent (), InsertPos->getIterator ());
8989}
9090
9191// / Insert an unlinked instruction into a basic block immediately after the
9292// / specified instruction.
9393void Instruction::insertAfter (Instruction *InsertPos) {
94- InsertPos->getParent ()->getInstList ().insertAfter (InsertPos->getIterator (),
95- this );
94+ insertAt (InsertPos->getParent (), std::next (InsertPos->getIterator ()));
9695}
9796
9897BasicBlock::iterator Instruction::insertAt (BasicBlock *BB,
0 commit comments