From ed5fdfba23ed1d25a07c0fbcccb8aaea138a5d88 Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Thu, 10 Nov 2016 11:06:32 +0000 Subject: [PATCH] debug/78112: remove recent duplicates for DW_TAG_subprogram attributes Disable unnecessary calls to dwarf2out_decl for the parents of nested functions. This fixes a libstdc++ build regression on x86_64-apple-darwin, as these calls used to add duplicate attributes (for instance DW_AT_inline and DW_AT_object_pointer) to the corresponding DW_TAG_subprogram DIE. Bootstrapped and regtested on x86_64-linux. gcc/ PR debug/78112 * dwarf2out.c (dwarf2out_early_global_decl): Call dwarf2out_decl on the context only when it has no DIE yet. testsuite/ PR debug/78112 * g++.dg/pr78112.C: New testcase Co-Authored-By: Jakub Jelinek From-SVN: r242035 --- gcc/ChangeLog | 6 ++ gcc/dwarf2out.c | 8 +- gcc/testsuite/ChangeLog | 6 ++ gcc/testsuite/g++.dg/pr78112.C | 162 +++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr78112.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5167edec046..f5c9add7720 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-10 Pierre-Marie de Rodat + + PR debug/78112 + * dwarf2out.c (dwarf2out_early_global_decl): Call dwarf2out_decl + on the context only when it has no DIE yet. + 2016-11-10 Richard Earnshaw * arm.h (target_cpus): Delete. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 1dfff38a862..f9ec0903b78 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -25256,11 +25256,11 @@ dwarf2out_early_global_decl (tree decl) if (!DECL_STRUCT_FUNCTION (decl)) goto early_decl_exit; - /* For nested functions, emit DIEs for the parents first so that all - nested DIEs are generated at the proper scope in the first - shot. */ + /* For nested functions, make sure we have DIEs for the parents first + so that all nested DIEs are generated at the proper scope in the + first shot. */ tree context = decl_function_context (decl); - if (context != NULL) + if (context != NULL && lookup_decl_die (context) == NULL) { current_function_decl = context; dwarf2out_decl (context); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 62cc516183b..9dfd15c5e45 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-11-10 Pierre-Marie de Rodat + Jakub Jelinek + + PR debug/78112 + * g++.dg/pr78112.C: New testcase + 2016-11-09 Jakub Jelinek * g++.dg/asan/asan_test.C: Remove -Wno-format, add diff --git a/gcc/testsuite/g++.dg/pr78112.C b/gcc/testsuite/g++.dg/pr78112.C new file mode 100644 index 00000000000..95d9e59fb64 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr78112.C @@ -0,0 +1,162 @@ +/* { dg-do compile } */ +/* { dg-options "-g -dA -std=gnu++11" } */ +/* { dg-final { scan-assembler-times DW_AT_inline 6 } } */ +/* { dg-final { scan-assembler-times DW_AT_object_pointer 37 } } */ +namespace std +{ +template struct integral_constant +{ + static constexpr _Tp value = 0; +}; +template using __bool_constant = integral_constant; +struct __not_ : integral_constant +{ +}; +template class _Op, + typename... _Args> +struct __detector +{ + using type = _Op<_Args...>; +}; +template class _Op, + typename... _Args> +using __detected_or = __detector<_Default, void, _Op, _Args...>; +template class _Op, + typename... _Args> +using __detected_or_t = typename __detected_or<_Default, _Op, _Args...>::type; +template