Issue description:
[oota-llvm.git] / lib / CodeGen / SelectionDAG / FastISel.cpp
index 818940490f11f54c679c5a9e2cd884af1f6bd0e9..4854cf7b261f6dc5de99668968ec4839d1fe8ef8 100644 (file)
@@ -53,7 +53,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/Analysis/Loads.h"
-#include "llvm/Target/TargetData.h"
+#include "llvm/DataLayout.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetLibraryInfo.h"
 #include "llvm/Target/TargetLowering.h"
@@ -149,13 +149,13 @@ unsigned FastISel::getRegForValue(const Value *V) {
        !FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(V))))
     return FuncInfo.InitializeRegForValue(V);
 
-  MachineBasicBlock::iterator SaveIter = enterLocalValueArea();
+  SavePoint SaveInsertPt = enterLocalValueArea();
 
   // Materialize the value in a register. Emit any instructions in the
   // local value area.
   Reg = materializeRegForValue(V, VT);
 
-  leaveLocalValueArea(SaveIter);
+  leaveLocalValueArea(SaveInsertPt);
 
   return Reg;
 }
@@ -238,16 +238,7 @@ unsigned FastISel::lookUpRegForValue(const Value *V) {
   DenseMap<const Value *, unsigned>::iterator I = FuncInfo.ValueMap.find(V);
   if (I != FuncInfo.ValueMap.end())
     return I->second;
-  unsigned Reg = LocalValueMap[V];
-
-  // If we managed to find a register here then go ahead and replace the
-  // current location with the location we're currently emitted for,
-  // 'moving' the value to a place that's closer to where it originally
-  // started.
-  if (Reg)
-    MRI.getVRegDef(Reg)->setDebugLoc(DL);
-
-  return Reg;
+  return LocalValueMap[V];
 }
 
 /// UpdateValueMap - Update the value map to include the new mapping for this
@@ -325,18 +316,22 @@ void FastISel::removeDeadCode(MachineBasicBlock::iterator I,
   recomputeInsertPt();
 }
 
-MachineBasicBlock::iterator FastISel::enterLocalValueArea() {
+FastISel::SavePoint FastISel::enterLocalValueArea() {
   MachineBasicBlock::iterator OldInsertPt = FuncInfo.InsertPt;
+  DebugLoc OldDL = DL;
   recomputeInsertPt();
-  return OldInsertPt;
+  DL = DebugLoc();
+  SavePoint SP = { OldInsertPt, OldDL };
+  return SP;
 }
 
-void FastISel::leaveLocalValueArea(MachineBasicBlock::iterator I) {
+void FastISel::leaveLocalValueArea(SavePoint OldInsertPt) {
   if (FuncInfo.InsertPt != FuncInfo.MBB->begin())
     LastLocalValue = llvm::prior(FuncInfo.InsertPt);
 
   // Restore the previous insert position.
-  FuncInfo.InsertPt = I;
+  FuncInfo.InsertPt = OldInsertPt.InsertPt;
+  DL = OldInsertPt.DL;
 }
 
 /// SelectBinaryOp - Select and emit code for a binary operator instruction,
@@ -1064,7 +1059,7 @@ FastISel::FastISel(FunctionLoweringInfo &funcInfo,
     MFI(*FuncInfo.MF->getFrameInfo()),
     MCP(*FuncInfo.MF->getConstantPool()),
     TM(FuncInfo.MF->getTarget()),
-    TD(*TM.getTargetData()),
+    TD(*TM.getDataLayout()),
     TII(*TM.getInstrInfo()),
     TLI(*TM.getTargetLowering()),
     TRI(*TM.getRegisterInfo()),