r188085 - Only emit debug info for implicit members that actually get codegen, not just ODR use.

Eric Christopher echristo at gmail.com
Fri Aug 9 10:35:30 PDT 2013


On Fri, Aug 9, 2013 at 10:20 AM, David Blaikie <dblaikie at gmail.com> wrote:
> Author: dblaikie
> Date: Fri Aug  9 12:20:05 2013
> New Revision: 188085
>
> URL: http://llvm.org/viewvc/llvm-project?rev=188085&view=rev
> Log:
> Only emit debug info for implicit members that actually get codegen, not just ODR use.
>
> This includes special members (copy/default ctor, copy assign, default
> ctor) and template specializations for member function templates.
>
> Good for a 5% decrease (1.80 to 1.71 GB) in size on Clang+LLVM's .dwo
> files (when using fission).
>

Cool deal. Nice patch.

-eric

> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>     cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
>     cfe/trunk/test/CodeGenCXX/debug-info.cpp
>     cfe/trunk/test/CodeGenCXX/debug-lambda-expressions.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=188085&r1=188084&r2=188085&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Aug  9 12:20:05 2013
> @@ -1129,16 +1129,11 @@ CollectCXXMemberFunctions(const CXXRecor
>    for(DeclContext::decl_iterator I = RD->decls_begin(),
>          E = RD->decls_end(); I != E; ++I) {
>      Decl *D = *I;
> -    if (D->isImplicit() && !D->isUsed())
> +    if (D->isImplicit())
>        continue;
>
>      if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
>        EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy));
> -    else if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(D))
> -      for (FunctionTemplateDecl::spec_iterator SI = FTD->spec_begin(),
> -             SE = FTD->spec_end(); SI != SE; ++SI)
> -        EltTys.push_back(CreateCXXMemberFunction(cast<CXXMethodDecl>(*SI), Unit,
> -                                                 RecordTy));
>    }
>  }
>
> @@ -2321,10 +2316,18 @@ llvm::DISubprogram CGDebugInfo::getFunct
>    if (!FD) return llvm::DISubprogram();
>
>    // Setup context.
> -  getContextDescriptor(cast<Decl>(D->getDeclContext()));
> +  llvm::DIScope S = getContextDescriptor(cast<Decl>(D->getDeclContext()));
>
>    llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator
>      MI = SPCache.find(FD->getCanonicalDecl());
> +  if (MI == SPCache.end()) {
> +    if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
> +      llvm::DICompositeType T(S);
> +      llvm::DISubprogram SP = CreateCXXMemberFunction(MD, getOrCreateFile(MD->getLocation()), T);
> +      T.addMember(SP);
> +      return SP;
> +    }
> +  }
>    if (MI != SPCache.end()) {
>      llvm::Value *V = MI->second;
>      llvm::DISubprogram SP(dyn_cast_or_null<llvm::MDNode>(V));
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp?rev=188085&r1=188084&r2=188085&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp Fri Aug  9 12:20:05 2013
> @@ -1,21 +1,19 @@
>  // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
>
> -class MyClass
> -{
> -public:
> -    int add2(int j)
> -    {
> -        return add<2>(j);
> -    }
> -private:
> -    template <int i> int add(int j)
> -    {
> -        return i + j;
> -    }
> +struct MyClass {
> +  template <int i> int add(int j) {
> +    return i + j;
> +  }
>  };
>
> -MyClass m;
> +int add2(int x) {
> +  return MyClass().add<2>(x);
> +}
>
> -// CHECK: metadata [[C_MEM:![0-9]*]], i32 0, null, null} ; [ DW_TAG_class_type ] [MyClass]
> -// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:![0-9]*]], metadata {{.*}}}
> -// CHECK: [[C_TEMP]] = {{.*}} ; [ DW_TAG_subprogram ] [line 11] [private] [add<2>]
> +inline int add3(int x) {
> +  return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it
> +}
> +
> +// CHECK: metadata [[C_MEM:![0-9]*]], i32 0, null, null} ; [ DW_TAG_structure_type ] [MyClass]
> +// CHECK: [[C_MEM]] = metadata !{metadata [[C_TEMP:![0-9]*]]}
> +// CHECK: [[C_TEMP]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>]
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info.cpp?rev=188085&r1=188084&r2=188085&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info.cpp Fri Aug  9 12:20:05 2013
> @@ -113,7 +113,7 @@ void func() {
>  }
>
>  // CHECK: metadata [[A_MEM:![0-9]*]], i32 0, null, null} ; [ DW_TAG_structure_type ] [a]
> -// CHECK: [[A_MEM]] = metadata !{metadata [[A_I:![0-9]*]], metadata !{{[0-9]*}}}
> +// CHECK: [[A_MEM]] = metadata !{metadata [[A_I:![0-9]*]]}
>  // CHECK: [[A_I]] = {{.*}} ; [ DW_TAG_member ] [i] {{.*}} [from int]
>  // CHECK: ; [ DW_TAG_structure_type ] [b] {{.*}}[decl]
>  }
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-lambda-expressions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-lambda-expressions.cpp?rev=188085&r1=188084&r2=188085&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-lambda-expressions.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-lambda-expressions.cpp Fri Aug  9 12:20:05 2013
> @@ -12,7 +12,7 @@ int b(int x) { return [x]{return x;}();
>  int c(int x) { return [&x]{return x;}(); }
>
>  struct D { D(); D(const D&); int x; };
> -int d(int x) { D y[10]; [x,y] { return y[x].x; }(); }
> +int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }
>
>  // Randomness for file. -- 6
>  // CHECK: [[FILE:.*]] = {{.*}} [ DW_TAG_file_type ] [{{.*}}debug-lambda-expressions.cpp]
> @@ -31,41 +31,37 @@ int d(int x) { D y[10]; [x,y] { return y
>
>  // Back to D. -- 24
>  // CHECK: [[LAM_D:.*]] = {{.*}}, metadata [[D_FUNC]], {{.*}}, metadata [[LAM_D_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[D_LINE]],
> -// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]], metadata [[DES_LAM_D:.*]]}
> +// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]]}
>  // CHECK: [[CAP_D_X]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_member ] [x] [line [[D_LINE]],
>  // CHECK: [[CAP_D_Y]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_member ] [y] [line [[D_LINE]],
>  // CHECK: [[CON_LAM_D]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE]]] [operator()]
> -// CHECK: [[DES_LAM_D]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE]]] [~]
>
>
>  // Back to C. -- 55
>  // CHECK: [[LAM_C:.*]] = {{.*}}, metadata [[C_FUNC]], {{.*}}, metadata [[LAM_C_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[C_LINE]],
> -// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]], metadata [[DES_LAM_C:.*]]}
> +// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]]}
>  // Ignoring the member type for now.
>  // CHECK: [[CAP_C]] = {{.*}}, metadata [[LAM_C]], {{.*}}} ; [ DW_TAG_member ] [x] [line [[C_LINE]],
>  // CHECK: [[CON_LAM_C]] = {{.*}}, metadata [[LAM_C]], {{.*}} [ DW_TAG_subprogram ] [line [[C_LINE]]] [operator()]
> -// CHECK: [[DES_LAM_C]] = {{.*}}, metadata [[LAM_C]], {{.*}} [ DW_TAG_subprogram ] [line [[C_LINE]]] [~]
>
>
>  // Back to B. -- 67
>  // CHECK: [[LAM_B:.*]] = {{.*}}, metadata [[B_FUNC]], {{.*}}, metadata [[LAM_B_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[B_LINE]],
> -// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]], metadata [[DES_LAM_B:.*]]}
> +// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]]}
>  // CHECK: [[CAP_B]] = {{.*}}, metadata [[LAM_B]], {{.*}}} ; [ DW_TAG_member ] [x] [line [[B_LINE]],
>  // CHECK: [[CON_LAM_B]] = {{.*}}, metadata [[LAM_B]], {{.*}} [ DW_TAG_subprogram ] [line [[B_LINE]]] [operator()]
> -// CHECK: [[DES_LAM_B]] = {{.*}}, metadata [[LAM_B]], {{.*}} [ DW_TAG_subprogram ] [line [[B_LINE]]] [~]
>
>  // Back to A. -- 78
>  // CHECK: [[LAM_A:.*]] = {{.*}}, metadata [[A_FUNC]], {{.*}}, metadata [[LAM_A_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[A_LINE]],
> -// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]], metadata [[DES_LAM_A:.*]]}
> +// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]]}
>  // CHECK: [[CON_LAM_A]] = {{.*}}, metadata [[LAM_A]], {{.*}} [ DW_TAG_subprogram ] [line [[A_LINE]]] [operator()]
> -// CHECK: [[DES_LAM_A]] = {{.*}}, metadata [[LAM_A]], {{.*}} [ DW_TAG_subprogram ] [line [[A_LINE]]] [~]
>
>  // CVAR:
>  // CHECK: {{.*}} metadata [[CVAR_T:![0-9]*]], {{.*}} ; [ DW_TAG_variable ] [cvar] [line [[CVAR_LINE:[0-9]*]]]
>  // CHECK: [[CVAR_T]] = {{.*}}, metadata ![[CVAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[CVAR_LINE]],
> -// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}}
> +// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}}
>
>  // VAR:
>  // CHECK: {{.*}} metadata [[VAR_T:![0-9]*]], {{.*}} ; [ DW_TAG_variable ] [var] [line [[VAR_LINE:[0-9]*]]]
>  // CHECK: [[VAR_T]] = {{.*}}, metadata [[VAR_ARGS:![0-9]*]], i32 0, null, null} ; [ DW_TAG_class_type ] [line [[VAR_LINE]],
> -// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}}
> +// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list