Move findDebugLoc somewhere more central. Fix
authorDale Johannesen <dalej@apple.com>
Wed, 20 Jan 2010 00:19:24 +0000 (00:19 +0000)
committerDale Johannesen <dalej@apple.com>
Wed, 20 Jan 2010 00:19:24 +0000 (00:19 +0000)
more cases where debug declarations affect
debug line info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93953 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineBasicBlock.h
lib/CodeGen/MachineBasicBlock.cpp
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86RegisterInfo.cpp

index 6b4c64055bf3beb941e4979872496074dd566c31..ad4bc1f79d54781125c7143e58422abea334ef76 100644 (file)
@@ -367,6 +367,9 @@ private:   // Methods used to maintain doubly linked list of blocks...
   void removePredecessor(MachineBasicBlock *pred);
 };
 
+DebugLoc
+findDebugLoc(MachineBasicBlock::iterator &MBBI, MachineBasicBlock &MBB);
+
 raw_ostream& operator<<(raw_ostream &OS, const MachineBasicBlock &MBB);
 
 void WriteAsOperand(raw_ostream &, const MachineBasicBlock*, bool t);
index 124f793962cdf747e40d4840b05be64bd517772d..030438fceb5af9316c1e274fe876d1942e5fe0dc 100644 (file)
@@ -528,3 +528,20 @@ void llvm::WriteAsOperand(raw_ostream &OS, const MachineBasicBlock *MBB,
                           bool t) {
   OS << "BB#" << MBB->getNumber();
 }
+
+/// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping
+/// any DEBUG_VALUE instructions.  Return UnknownLoc if there is none.
+DebugLoc
+llvm::findDebugLoc(MachineBasicBlock::iterator &MBBI, MachineBasicBlock &MBB) {
+  DebugLoc DL;
+  if (MBBI != MBB.end()) {
+    // Skip debug declarations, we don't want a DebugLoc from them.
+    MachineBasicBlock::iterator MBBI2 = MBBI;
+    while (MBBI2 != MBB.end() &&
+           MBBI2->getOpcode()==TargetInstrInfo::DEBUG_VALUE)
+      MBBI2++;
+    if (MBBI2 != MBB.end())
+      DL = MBBI2->getDebugLoc();
+  }
+  return DL;
+}
index 8b9d0b80babb53a988d88775fb6a27c2398ce02c..9501ace8d374c21442f14e62d350ac45ea7bd0c2 100644 (file)
@@ -2200,8 +2200,7 @@ bool X86InstrInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB,
   if (CSI.empty())
     return false;
 
-  DebugLoc DL = DebugLoc::getUnknownLoc();
-  if (MI != MBB.end()) DL = MI->getDebugLoc();
+  DebugLoc DL = findDebugLoc(MI, MBB);
 
   bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
   bool isWin64 = TM.getSubtarget<X86Subtarget>().isTargetWin64();
@@ -2239,8 +2238,7 @@ bool X86InstrInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
   if (CSI.empty())
     return false;
 
-  DebugLoc DL = DebugLoc::getUnknownLoc();
-  if (MI != MBB.end()) DL = MI->getDebugLoc();
+  DebugLoc DL = findDebugLoc(MI, MBB);
 
   MachineFunction &MF = *MBB.getParent();
   unsigned FPReg = RI.getFrameRegister(MF);
index 60e69e8d5148647abed1e3cb162f8f1adb9f6b30..6962b8cef9559d75fc67c1e4eba81871b8a7e68a 100644 (file)
@@ -666,23 +666,6 @@ X86RegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
   }
 }
 
-/// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping
-/// any DEBUG_VALUE instructions.  Return UnknownLoc if there is none.
-static
-DebugLoc findDebugLoc(MachineBasicBlock::iterator &MBBI, MachineBasicBlock &MBB) {
-  DebugLoc DL;
-  if (MBBI != MBB.end()) {
-    // Skip debug declarations, we don't want a DebugLoc from them.
-    MachineBasicBlock::iterator MBBI2 = MBBI;
-    while (MBBI2 != MBB.end() &&
-           MBBI2->getOpcode()==TargetInstrInfo::DEBUG_VALUE)
-      MBBI2++;
-    if (MBBI2 != MBB.end())
-      DL = MBBI2->getDebugLoc();
-  }
-  return DL;
-}
-
 /// emitSPUpdate - Emit a series of instructions to increment / decrement the
 /// stack pointer by a constant value.
 static