Fixed up my changes to add support for cloning Machine Instructions.
authorTanya Lattner <tonic@nondot.org>
Sun, 23 May 2004 20:58:02 +0000 (20:58 +0000)
committerTanya Lattner <tonic@nondot.org>
Sun, 23 May 2004 20:58:02 +0000 (20:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13665 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstr.h
lib/CodeGen/MachineInstr.cpp

index b6c18610ad3a65635b96c29da914206fc6601e84..a488b45f7811f15624b24eb66e9b4bd23602e815 100644 (file)
@@ -398,9 +398,6 @@ public:
   const MachineBasicBlock* getParent() const { return parent; }
   MachineBasicBlock* getParent() { return parent; }
 
-  //void setParent(const MachineBasicBlock *MBB) { parent = MBB; } 
-  void setParent(MachineBasicBlock *MBB) { parent = MBB; } 
-
   /// getOpcode - Returns the opcode of this MachineInstr.
   ///
   const int getOpcode() const { return Opcode; }
@@ -461,10 +458,8 @@ public:
                          MachineOperand::MO_VirtualRegister, V);
   }
 
-  //Clone Instruction 
-  //Create a copy of 'this' instruction that is
-  //identical in all ways except the following: The instruction has no
-  //parent The instruction has no name
+  /// clone - Create a copy of 'this' instruction that is identical in
+  /// all ways except the the instruction has no parent, prev, or next.
   MachineInstr* clone();
 
   //
index e1e44fd47e09e5abf8abb2a40e682ff7e9968294..401cd8b417238b7ea419239b4778f931f182647c 100644 (file)
@@ -73,7 +73,8 @@ MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode,
 MachineInstr::MachineInstr(const MachineInstr &MI) {
   Opcode = MI.getOpcode();
   numImplicitRefs = MI.getNumImplicitRefs();
+  operands.reserve(MI.getNumOperands());
+
   //Add operands
   for(unsigned i=0; i < MI.getNumOperands(); ++i)
     operands.push_back(MachineOperand(MI.getOperand(i)));
@@ -89,7 +90,7 @@ MachineInstr::~MachineInstr()
 ///all ways except the following: The instruction has no parent The
 ///instruction has no name
 MachineInstr* MachineInstr::clone() {
-  MachineInstr* newInst = new MachineInstr(*this);
+  return new MachineInstr(*this);
 }
 
 /// OperandComplete - Return true if it's illegal to add a new operand