Speculatively revert r123032.
authorDevang Patel <dpatel@apple.com>
Fri, 7 Jan 2011 22:33:41 +0000 (22:33 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 7 Jan 2011 22:33:41 +0000 (22:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123039 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/LiveDebugVariables.cpp
test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
test/CodeGen/X86/2010-05-28-Crash.ll
test/CodeGen/X86/dbg-value-range.ll

index db03ed954ece1e4c240c49b4b4b62bbb1fdffa29..0ebd94a01265cf641c3d7f309e2185ba73be8a11 100644 (file)
@@ -2257,6 +2257,15 @@ DwarfDebug::collectVariableInfoFromMMITable(const MachineFunction * MF,
   }
 }
 
+/// isDbgValueInUndefinedReg - Return true if debug value, encoded by
+/// DBG_VALUE instruction, is in undefined reg.
+static bool isDbgValueInUndefinedReg(const MachineInstr *MI) {
+  assert (MI->isDebugValue() && "Invalid DBG_VALUE machine instruction!");
+  if (MI->getOperand(0).isReg() && !MI->getOperand(0).getReg())
+    return true;
+  return false;
+}
+
 /// isDbgValueInDefinedReg - Return true if debug value, encoded by
 /// DBG_VALUE instruction, is in a defined reg.
 static bool isDbgValueInDefinedReg(const MachineInstr *MI) {
@@ -2281,7 +2290,7 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
     for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
          II != IE; ++II) {
       const MachineInstr *MInsn = II;
-      if (!MInsn->isDebugValue())
+      if (!MInsn->isDebugValue() || isDbgValueInUndefinedReg(MInsn))
         continue;
       DbgValues.push_back(MInsn);
     }
@@ -2303,18 +2312,19 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
            ME = DbgValues.end(); MI != ME; ++MI) {
       const MDNode *Var =
         (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata();
-      if (Var == DV && 
+      if (Var == DV && isDbgValueInDefinedReg(*MI) &&
           !PrevMI->isIdenticalTo(*MI))
         MultipleValues.push_back(*MI);
       PrevMI = *MI;
     }
 
-    DbgScope *Scope = NULL;
+    DbgScope *Scope = findDbgScope(MInsn);
+    bool CurFnArg = false;
     if (DV.getTag() == dwarf::DW_TAG_arg_variable &&
         DISubprogram(DV.getContext()).describes(MF->getFunction()))
+      CurFnArg = true;
+    if (!Scope && CurFnArg)
       Scope = CurrentFnDbgScope;
-    else
-      Scope = findDbgScope(MInsn);
     // If variable scope is not found then skip this variable.
     if (!Scope)
       continue;
index 2b6a54eab5ad654e47aed9e9f0919289493d176b..baedfc3efb5c49a14d931dc2bce45a0ee0f6322f 100644 (file)
 
 using namespace llvm;
 
+static cl::opt<bool>
+EnableLDV("live-debug-variables",
+          cl::desc("Enable the live debug variables pass"), cl::Hidden);
+
 char LiveDebugVariables::ID = 0;
 
 INITIALIZE_PASS_BEGIN(LiveDebugVariables, "livedebugvars",
@@ -618,6 +622,8 @@ bool LDVImpl::runOnMachineFunction(MachineFunction &mf) {
 }
 
 bool LiveDebugVariables::runOnMachineFunction(MachineFunction &mf) {
+  if (!EnableLDV)
+    return false;
   if (!pImpl)
     pImpl = new LDVImpl(this);
   return static_cast<LDVImpl*>(pImpl)->runOnMachineFunction(mf);
index 60171eb62973bb94506317618c06409143c028de..13f72a99d2b2655218cd24859ca303bb9d2a0520 100644 (file)
@@ -61,6 +61,6 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
 ; CHECK-NEXT: .short  1
 ; CHECK-NEXT: .byte   85
 ; CHECK-NEXT: .quad   Ltmp3
-; CHECK-NEXT: .quad   Ltmp6
+; CHECK-NEXT: .quad   Lfunc_end
 ; CHECK-NEXT: .short  1
 ; CHECK-NEXT: .byte   83
index b504badc2e17ccb1b490f859e1888f64c8e159ab..80643d0792acfa4aec55c768c05cad1715b5df12 100644 (file)
@@ -39,5 +39,6 @@ entry:
 !13 = metadata !{i32 7, i32 0, metadata !14, null}
 !14 = metadata !{i32 524299, metadata !8, i32 6, i32 0} ; [ DW_TAG_lexical_block ]
 
-;CHECK:Ltmp8
+;CHECK:                DEBUG_VALUE: bar:x <- EBX+0
+;CHECK-NEXT:Ltmp
 ;CHECK-NEXT:   DEBUG_VALUE: foo:y <- 1+0
index 4d615d7c82d169aaec3c841ed0a1ddc8e31ea11b..1ea009e14a7f15c02f53c06d1300d35e2ee441cd 100644 (file)
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s
+; XFAIL: *
 
 %struct.a = type { i32 }