[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Fri Jun 25 02:24:02 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

UnpackTraceFunction.cpp updated: 1.87 -> 1.88

---
Log message:

Don't unwittingly dereference mvec.end()


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

Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.87 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.88
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.87	Fri Jun 25 01:07:40 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp	Fri Jun 25 02:22:23 2004
@@ -277,16 +277,17 @@
 // or    %B, %A, %B<d>
 // or    %B, %lo(<cp#0>), %B<d>
 // ldd   %B, 0, %C<d>
-static void regAllocConstLDDFi (std::vector<MachineInstr *> &mvec,  unsigned DestReg, unsigned SpareReg) {
-  std::vector<MachineInstr *>::iterator first = mvec.begin (),
-  last = mvec.end ();
-  Value *TopHalfVReg = (*first)->getOperand(1).getVRegValue (),
-    *BottomHalfVReg = (*last)->getOperand (0).getVRegValue (),
-    *DestVReg = (*last)->getOperand (2).getVRegValue ();
+static void regAllocConstLDDFi (std::vector<MachineInstr *> &mvec, 
+                                unsigned DestReg, unsigned SpareReg) {
+  MachineInstr *&first = mvec.front (), *&last = mvec.back ();
+  Value *TopHalfVReg = first->getOperand (1).getVRegValue (),
+    *BottomHalfVReg = last->getOperand (0).getVRegValue (),
+    *DestVReg = last->getOperand (2).getVRegValue ();
   
-  for (std::vector<MachineInstr *>::iterator i = first; i != last; ++i) {
+  for (std::vector<MachineInstr *>::iterator i = mvec.begin (),
+       e = mvec.end(); i != e; ++i) {
     MachineInstr &MInst = **i;
-    for (unsigned opNum=0, last=MInst.getNumOperands (); opNum != last;
+    for (unsigned opNum=0, nOps=MInst.getNumOperands (); opNum != nOps;
          ++opNum) {
       MachineOperand &Op = MInst.getOperand (opNum);
       if (Op.getType() == MachineOperand::MO_VirtualRegister) {





More information about the llvm-commits mailing list