r188834 - DebugInfo: comment/inlining based on feedback from Eric & Adrian

David Blaikie dblaikie at gmail.com
Tue Aug 20 14:49:22 PDT 2013


Author: dblaikie
Date: Tue Aug 20 16:49:21 2013
New Revision: 188834

URL: http://llvm.org/viewvc/llvm-project?rev=188834&view=rev
Log:
DebugInfo: comment/inlining based on feedback from Eric & Adrian

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=188834&r1=188833&r2=188834&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 20 16:49:21 2013
@@ -946,9 +946,18 @@ void CGDebugInfo::CollectRecordFields(co
     // the corresponding declarations in the source program.
     for (RecordDecl::decl_iterator I = record->decls_begin(),
            E = record->decls_end(); I != E; ++I)
-      if (const VarDecl *V = dyn_cast<VarDecl>(*I))
-        elements.push_back(getOrCreateStaticDataMemberDeclaration(V, RecordTy));
-      else if (FieldDecl *field = dyn_cast<FieldDecl>(*I)) {
+      if (const VarDecl *V = dyn_cast<VarDecl>(*I)) {
+        // Reuse the existing static member declaration if one exists
+        llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =
+            StaticDataMemberCache.find(V->getCanonicalDecl());
+        if (MI != StaticDataMemberCache.end()) {
+          assert(MI->second &&
+                 "Static data member declaration should still exist");
+          elements.push_back(
+              llvm::DIDerivedType(cast<llvm::MDNode>(MI->second)));
+        } else
+          elements.push_back(CreateRecordStaticField(V, RecordTy));
+      } else if (FieldDecl *field = dyn_cast<FieldDecl>(*I)) {
         CollectRecordNormalField(field, layout.getFieldOffset(fieldNo),
                                  tunit, elements, RecordTy);
 
@@ -1123,6 +1132,7 @@ CollectCXXMemberFunctions(const CXXRecor
       continue;
 
     if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
+      // Reuse the existing member function declaration if it exists
       llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
           SPCache.find(Method->getCanonicalDecl());
       if (MI == SPCache.end())
@@ -3067,6 +3077,9 @@ CGDebugInfo::getOrCreateStaticDataMember
     assert(MI->second && "Static data member declaration should still exist");
     return llvm::DIDerivedType(cast<llvm::MDNode>(MI->second));
   }
+
+  // If the member wasn't found in the cache, lazily construct and add it to the
+  // type (used when a limited form of the type is emitted).
   llvm::DICompositeType Ctxt(
       getContextDescriptor(cast<Decl>(D->getDeclContext())));
   llvm::DIDerivedType T = CreateRecordStaticField(D, Ctxt);
@@ -3074,18 +3087,6 @@ CGDebugInfo::getOrCreateStaticDataMember
   return T;
 }
 
-llvm::DIDerivedType
-CGDebugInfo::getOrCreateStaticDataMemberDeclaration(const VarDecl *D,
-                                            llvm::DICompositeType Ctxt) {
-  llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =
-      StaticDataMemberCache.find(D->getCanonicalDecl());
-  if (MI != StaticDataMemberCache.end()) {
-    assert(MI->second && "Static data member declaration should still exist");
-    return llvm::DIDerivedType(cast<llvm::MDNode>(MI->second));
-  }
-  return CreateRecordStaticField(D, Ctxt);
-}
-
 /// EmitGlobalVariable - Emit information about a global variable.
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
                                      const VarDecl *D) {

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=188834&r1=188833&r2=188834&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Aug 20 16:49:21 2013
@@ -359,9 +359,6 @@ private:
   /// declaration for the given out-of-class definition.
   llvm::DIDerivedType
   getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D);
-  llvm::DIDerivedType
-  getOrCreateStaticDataMemberDeclaration(const VarDecl *D,
-                                         llvm::DICompositeType Ctxt);
 
   /// getFunctionName - Get function name for the given FunctionDecl. If the
   /// name is constructred on demand (e.g. C++ destructor) then the name





More information about the cfe-commits mailing list