DBG_VALUE machine instruction pointing to undefined register for a variable justify...
authorDevang Patel <dpatel@apple.com>
Thu, 24 Jun 2010 21:51:19 +0000 (21:51 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 24 Jun 2010 21:51:19 +0000 (21:51 +0000)
Radar 8122864.

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

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/FrontendC/2010-06-24-DbgInlinedFnParameter.c [new file with mode: 0644]

index 89993ae9fd4192e392aeab52e0d0ce21e4185608..abd42dcdf4ceb1ca70a27c8c7c58c79bde92afc1 100644 (file)
@@ -2390,8 +2390,6 @@ DbgScope *DwarfDebug::getOrCreateDbgScope(const MDNode *Scope, const MDNode *Inl
 static bool hasValidLocation(LLVMContext &Ctx,
                              const MachineInstr *MInsn,
                              const MDNode *&Scope, const MDNode *&InlinedAt) {
-  if (MInsn->isDebugValue())
-    return false;
   DebugLoc DL = MInsn->getDebugLoc();
   if (DL.isUnknown()) return false;
       
@@ -2655,7 +2653,6 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
         assert (MI->getNumOperands() > 1 && "Invalid machine instruction!");
         DIVariable DV(MI->getOperand(MI->getNumOperands() - 1).getMetadata());
         if (!DV.Verify()) continue;
-        if (isDbgValueInUndefinedReg(MI)) continue;
         // If DBG_VALUE is for a local variable then it needs a label.
         if (DV.getTag() != dwarf::DW_TAG_arg_variable)
           InsnNeedsLabel.insert(MI);
@@ -2663,7 +2660,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
         else if (!DISubprogram(DV.getContext()).describes(MF->getFunction()))
           InsnNeedsLabel.insert(MI);
         // DBG_VALUE indicating argument location change needs a label.
-        else if (!ProcessedArgs.insert(DV))
+        else if (isDbgValueInUndefinedReg(MI) == false && !ProcessedArgs.insert(DV))
           InsnNeedsLabel.insert(MI);
       } else {
         // If location is unknown then instruction needs a location only if 
diff --git a/test/FrontendC/2010-06-24-DbgInlinedFnParameter.c b/test/FrontendC/2010-06-24-DbgInlinedFnParameter.c
new file mode 100644 (file)
index 0000000..15d3a1f
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %llvmgcc -S -O2 -g %s -o - | llc -O2 -o %t.s
+// RUN: grep  "# DW_TAG_formal_parameter" %t.s | count 4
+// Radar 8122864
+static int foo(int a, int j) {
+  int k = 0;
+  if (a)
+    k = a + j;
+  else
+    k = j;
+  return k;
+}
+int bar(int o, int p) {
+
+  return foo(o, p);
+}