DebugInfo: Omit DW_AT_artificial on DW_TAG_formal_parameters in DW_TAG_inlined_subrou...
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 30 Apr 2014 22:41:33 +0000 (22:41 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 30 Apr 2014 22:41:33 +0000 (22:41 +0000)
They just don't need to be there - they're inherited from the abstract
definition. In theory I would like them to be inherited from the
declaration, but the DWARF standard doesn't quite say that... we can
probably do it anyway but I'm less confident about that so I'll leave it
for a separate commit.

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

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.h
test/DebugInfo/X86/inline-member-function.ll

index d3309c1e6e8aa44b5d1bd8ce0ef8e868c796d1d5..6960ec94551d904bca59352801d64bf5fbec9860 100644 (file)
@@ -509,6 +509,21 @@ DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit &TheCU,
   return ScopeDIE;
 }
 
+static std::unique_ptr<DIE> constructVariableDIE(DwarfCompileUnit &TheCU,
+                                                 DbgVariable &DV,
+                                                 const LexicalScope &Scope,
+                                                 DIE *&ObjectPointer) {
+  AbstractOrInlined AOI = AOI_None;
+  if (Scope.isAbstractScope())
+    AOI = AOI_Abstract;
+  else if (Scope.getInlinedAt())
+    AOI = AOI_Inlined;
+  auto Var = TheCU.constructVariableDIE(DV, AOI);
+  if (DV.isObjectPointer())
+    ObjectPointer = Var.get();
+  return Var;
+}
+
 DIE *DwarfDebug::createScopeChildrenDIE(
     DwarfCompileUnit &TheCU, LexicalScope *Scope,
     SmallVectorImpl<std::unique_ptr<DIE>> &Children) {
@@ -517,12 +532,9 @@ DIE *DwarfDebug::createScopeChildrenDIE(
   // Collect arguments for current function.
   if (LScopes.isCurrentFunctionScope(Scope)) {
     for (DbgVariable *ArgDV : CurrentFnArguments)
-      if (ArgDV) {
+      if (ArgDV)
         Children.push_back(
-            TheCU.constructVariableDIE(*ArgDV, Scope->isAbstractScope()));
-        if (ArgDV->isObjectPointer())
-          ObjectPointer = Children.back().get();
-      }
+            constructVariableDIE(TheCU, *ArgDV, *Scope, ObjectPointer));
 
     // If this is a variadic function, add an unspecified parameter.
     DISubprogram SP(Scope->getScopeNode());
@@ -535,12 +547,9 @@ DIE *DwarfDebug::createScopeChildrenDIE(
   }
 
   // Collect lexical scope children first.
-  for (DbgVariable *DV : ScopeVariables.lookup(Scope)) {
-    Children.push_back(
-        TheCU.constructVariableDIE(*DV, Scope->isAbstractScope()));
-    if (DV->isObjectPointer())
-      ObjectPointer = Children.back().get();
-  }
+  for (DbgVariable *DV : ScopeVariables.lookup(Scope))
+    Children.push_back(constructVariableDIE(TheCU, *DV, *Scope, ObjectPointer));
+
   for (LexicalScope *LS : Scope->getChildren())
     if (std::unique_ptr<DIE> Nested = constructScopeDIE(TheCU, LS))
       Children.push_back(std::move(Nested));
@@ -897,7 +906,7 @@ void DwarfDebug::collectDeadVariables() {
           if (!DV.isVariable())
             continue;
           DbgVariable NewVar(DV, nullptr, this);
-          SPDIE->addChild(SPCU->constructVariableDIE(NewVar, false));
+          SPDIE->addChild(SPCU->constructVariableDIE(NewVar));
         }
       }
     }
index 852eda14d867fb3255c9abbd0d15c1f8589c4515..d37dcf273785e36db216ca8b8bf178511fd3f0e3 100644 (file)
@@ -1807,14 +1807,15 @@ void DwarfUnit::constructContainingTypeDIEs() {
 
 /// constructVariableDIE - Construct a DIE for the given DbgVariable.
 std::unique_ptr<DIE> DwarfUnit::constructVariableDIE(DbgVariable &DV,
-                                                     bool isScopeAbstract) {
-  auto D = constructVariableDIEImpl(DV, isScopeAbstract);
+                                                     AbstractOrInlined AbsIn) {
+  auto D = constructVariableDIEImpl(DV, AbsIn);
   DV.setDIE(*D);
   return D;
 }
 
-std::unique_ptr<DIE> DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
-                                                         bool isScopeAbstract) {
+std::unique_ptr<DIE>
+DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
+                                    AbstractOrInlined AbsIn) {
   StringRef Name = DV.getName();
 
   // Define variable debug information entry.
@@ -1830,10 +1831,10 @@ std::unique_ptr<DIE> DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
     addType(*VariableDie, DV.getType());
   }
 
-  if (DV.isArtificial())
+  if (AbsIn != AOI_Inlined && DV.isArtificial())
     addFlag(*VariableDie, dwarf::DW_AT_artificial);
 
-  if (isScopeAbstract)
+  if (AbsIn == AOI_Abstract)
     return VariableDie;
 
   // Add variable address.
index cf4bc991b25c2371222dda411004be194b73b919..5beae1e29c48101be43259b347b0524c10505695 100644 (file)
@@ -61,6 +61,8 @@ public:
   void addRange(RangeSpan Range) { Ranges.push_back(Range); }
 };
 
+enum AbstractOrInlined { AOI_None, AOI_Inlined, AOI_Abstract };
+
 //===----------------------------------------------------------------------===//
 /// Unit - This dwarf writer support class manages information associated
 /// with a source file.
@@ -413,7 +415,7 @@ public:
 
   /// constructVariableDIE - Construct a DIE for the given DbgVariable.
   std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
-                                            bool isScopeAbstract);
+                                            AbstractOrInlined AbsIn = AOI_None);
 
   /// constructSubprogramArguments - Construct function argument DIEs.
   DIE *constructSubprogramArguments(DIE &Buffer, DIArray Args);
@@ -451,7 +453,7 @@ private:
   /// \brief Construct a DIE for the given DbgVariable without initializing the
   /// DbgVariable's DIE reference.
   std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
-                                                bool isScopeAbstract);
+                                                AbstractOrInlined AbsIn);
 
   /// constructTypeDIE - Construct basic type die from DIBasicType.
   void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
index 791d64667198cc06fbb409595892f5808713a271..a3fcb99c5ced9eae45a5eb46cc5b63ef701a5ecd 100644 (file)
@@ -18,6 +18,8 @@
 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}}{[[ABSTRACT_ORIGIN:0x[0-9a-e]*]]}
 ; CHECK-NOT: NULL
 ; CHECK-NOT: DW_AT_object_pointer
+; CHECK: DW_TAG_formal_parameter
+; CHECK-NOT: DW_AT_artificial
 ; CHECK: DW_TAG
 
 ; But make sure we emit DW_AT_object_pointer on the declaration.