r204874 - Just call getContextDescriptor to get the context for subprograms

David Blaikie dblaikie at gmail.com
Wed Mar 26 16:27:11 PDT 2014


On Wed, Mar 26, 2014 at 4:09 PM, Eric Christopher <echristo at gmail.com> wrote:
> Author: echristo
> Date: Wed Mar 26 18:09:30 2014
> New Revision: 204874
>
> URL: http://llvm.org/viewvc/llvm-project?rev=204874&view=rev
> Log:
> Just call getContextDescriptor to get the context for subprograms
> instead of rolling an inefficient version of the function. This
> changes some order of emission of metadata nodes, fix up those
> testcases and make them more flexible to some changes.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>     cfe/trunk/test/CodeGenCXX/debug-info-function-context.cpp
>     cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=204874&r1=204873&r2=204874&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Mar 26 18:09:30 2014
> @@ -2541,15 +2541,10 @@ void CGDebugInfo::EmitFunctionStart(Glob
>           DebugKind <= CodeGenOptions::DebugLineTablesOnly))
>        LinkageName = StringRef();
>
> +    // If we aren't in line table only mode then grab a full context and
> +    // template parameters for the function.
>      if (DebugKind >= CodeGenOptions::LimitedDebugInfo) {
> -      if (const NamespaceDecl *NSDecl =
> -              dyn_cast_or_null<NamespaceDecl>(FD->getDeclContext()))
> -        FDContext = getOrCreateNameSpace(NSDecl);
> -      else if (const RecordDecl *RDecl =
> -                   dyn_cast_or_null<RecordDecl>(FD->getDeclContext()))
> -        FDContext = getContextDescriptor(cast<Decl>(RDecl));
> -
> -      // Collect template parameters.
> +      FDContext = getContextDescriptor(cast<Decl>(FD->getDeclContext()));

Could you explain why this change caused changes in the IR output?

I assume the changes are just reorderings - but even reorderings
surprise me here. For namespace lookups I wouldn't've expected them to
be found in the "RegionMap" (CGDebugInfo::getOrCreateNamespace doesn't
appear to add namespaces to any cache other than the NameSpaceCache,
not the RegionMap) and in the other case is the same before and
after...

>        TParamsArray = CollectFunctionTemplateParams(FD, Unit);
>      }
>    } else if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)) {
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-function-context.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-function-context.cpp?rev=204874&r1=204873&r2=204874&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-function-context.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-function-context.cpp Wed Mar 26 18:09:30 2014
> @@ -25,12 +25,10 @@ int global_namespace_variable = 1;
>  // functions that belong to the namespace have it as a context, and the global
>  // function has the file as a context.
>
> +// CHECK: [[FILE:![0-9]*]] {{.*}}debug-info-function-context.cpp"
>  // CHECK: metadata !"_ZTS1C", metadata !"member_function"{{.*}} [ DW_TAG_subprogram ] [line 11] [def] [member_function]
> -
>  // CHECK: metadata !"_ZTS1C", metadata !"static_member_function"{{.*}}  [ DW_TAG_subprogram ] [line 13] [def] [static_member_function]
> +// CHECK: metadata [[FILE]], null, metadata !"global_function"{{.*}}  [ DW_TAG_subprogram ] [line 17] [def] [global_function]
> +// CHECK: metadata [[NS:![0-9]*]], metadata !"global_namespace_function"{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function]
> +// CHECK: [[NS]] = {{.*}}, metadata [[FILE]], null, metadata !"ns", {{.*}} ; [ DW_TAG_namespace ] [ns] [line 19]
>
> -// CHECK: metadata !22, metadata !"global_function"{{.*}}  [ DW_TAG_subprogram ] [line 17] [def] [global_function]
> -// CHECK: !22 = {{.*}} [ DW_TAG_file_type ]
> -
> -// CHECK: metadata !24, metadata !"global_namespace_function"{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function]
> -// CHECK: !24 = {{.*}} [ DW_TAG_namespace ] [ns] [line 19]
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp?rev=204874&r1=204873&r2=204874&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp Wed Mar 26 18:09:30 2014
> @@ -52,8 +52,8 @@ using B::i;
>  // CHECK: [[BAR:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [decl] [from ]
>  // CHECK: [[F1:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 4] [def] [f1]
>  // CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
> -// CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp]
>  // CHECK: [[I:![0-9]*]] = {{.*}}, metadata [[NS]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i]
> +// CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp]
>  // CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]], metadata [[M5:![0-9]*]], metadata [[M6:![0-9]*]], metadata [[M7:![0-9]*]], metadata [[M8:![0-9]*]], metadata [[M9:![0-9]*]], metadata [[M10:![0-9]*]], metadata [[M11:![0-9]*]], metadata [[M12:![0-9]*]], metadata [[M13:![0-9]*]]}
>  // CHECK: [[M1]] = metadata !{i32 {{[0-9]*}}, metadata [[CTXT]], metadata [[NS]], i32 11} ; [ DW_TAG_imported_module ]
>  // CHECK: [[M2]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_module ]
>
>
> _______________________________________________
> 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