Fix incorrect atomics codegen introduced in r154705, and extend test to catch it.
[oota-llvm.git] / lib / CodeGen / AntiDepBreaker.h
index dac700076a8ec9f8e959e956c833205095b481cf..df47f984d57817bdd75e1b21eff31b9eb1c07325 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
 #include "llvm/Target/TargetRegisterInfo.h"
+#include <vector>
 
 namespace llvm {
 
@@ -29,11 +30,10 @@ namespace llvm {
 /// anti-dependencies.
 class AntiDepBreaker {
 public:
-  virtual ~AntiDepBreaker();
+  typedef std::vector<std::pair<MachineInstr *, MachineInstr *> > 
+    DbgValueVector;
 
-  /// GetMaxTrials - Return the maximum number of anti-dependence
-  /// breaking attempts that will be made for a block.
-  virtual unsigned GetMaxTrials() =0;
+  virtual ~AntiDepBreaker();
 
   /// Start - Initialize anti-dep breaking for a new basic block.
   virtual void StartBlock(MachineBasicBlock *BB) =0;
@@ -42,10 +42,11 @@ public:
   /// basic-block region and break them by renaming registers. Return
   /// the number of anti-dependencies broken.
   ///
-  virtual unsigned BreakAntiDependencies(std::vector<SUnit>& SUnits,
-                                         MachineBasicBlock::iterator& Begin,
-                                         MachineBasicBlock::iterator& End,
-                                         unsigned InsertPosIndex) =0;
+  virtual unsigned BreakAntiDependencies(const std::vector<SUnit>& SUnits,
+                                         MachineBasicBlock::iterator Begin,
+                                         MachineBasicBlock::iterator End,
+                                         unsigned InsertPosIndex,
+                                         DbgValueVector &DbgValues) = 0;
   
   /// Observe - Update liveness information to account for the current
   /// instruction, which will not be scheduled.
@@ -55,6 +56,14 @@ public:
   
   /// Finish - Finish anti-dep breaking for a basic block.
   virtual void FinishBlock() =0;
+
+  /// UpdateDbgValue - Update DBG_VALUE if dependency breaker is updating
+  /// other machine instruction to use NewReg.
+  void UpdateDbgValue(MachineInstr *MI, unsigned OldReg, unsigned NewReg) {
+    assert (MI->isDebugValue() && "MI is not DBG_VALUE!");
+    if (MI && MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == OldReg)
+      MI->getOperand(0).setReg(NewReg);
+  }
 };
 
 }