From 80da865f77a57c0dd923d6cea8a9619368e4e91b Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Thu, 12 Feb 2004 02:27:10 +0000 Subject: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. llvm-svn: 11340 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llvm/lib/CodeGen/TwoAddressInstructionPass.cpp') diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index 497cf634a9d..3f99f2a4794 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -84,9 +84,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::iterator mbbi = MF.begin(), mbbe = MF.end(); mbbi != mbbe; ++mbbi) { - for (MachineBasicBlock::iterator mii = mbbi->begin(); - mii != mbbi->end(); ++mii) { - MachineInstr* mi = *mii; + for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); + mi != me; ++mi) { unsigned opcode = mi->getOpcode(); // ignore if it is not a two-address instruction @@ -132,10 +131,11 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { const TargetRegisterClass* rc = MF.getSSARegMap()->getRegClass(regA); - unsigned Added = MRI.copyRegToReg(*mbbi, mii, regA, regB, rc); + unsigned Added = MRI.copyRegToReg(*mbbi, mi, regA, regB, rc); numInstrsAdded += Added; - MachineInstr* prevMi = *(mii - 1); + MachineBasicBlock::iterator prevMi = mi; + --prevMi; DEBUG(std::cerr << "\t\tadded instruction: "; prevMi->print(std::cerr, TM)); -- cgit v1.2.3