gcc/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc
Richard Biener c6ef9d8d3f debug/96383 - emit debug info for used external functions
This makes sure to emit full declaration DIEs including
formal parameters for used external functions.  This helps
debugging when debug information of the external entity is
not available and also helps external tools cross-checking
ABI compatibility which was the bug reporters use case.

For cc1 this affects debug information size as follows:

     VM SIZE                     FILE SIZE
 ++++++++++++++ GROWING       ++++++++++++++
  [ = ]       0 .debug_info   +1.63Mi  +1.3%
  [ = ]       0 .debug_str     +263Ki  +3.4%
  [ = ]       0 .debug_abbrev  +101Ki  +4.9%
  [ = ]       0 .debug_line   +5.71Ki  +0.0%
   +44%     +16 [Unmapped]        +48  +1.2%

 -------------- SHRINKING     --------------
  [ = ]       0 .debug_loc       -213  -0.0%
  -0.0%     -48 .text             -48  -0.0%
  [ = ]       0 .debug_ranges     -16  -0.0%

  -0.0%     -32 TOTAL         +1.99Mi  +0.6%

and DWARF compression via DWZ can only shave off minor bits
here.

Previously we emitted no DIEs for external functions at all
unless they were referenced via DW_TAG_GNU_call_site which
for some GCC revs caused a regular DIE to appear and since
GCC 4.9 only a stub without formal parameters.  This means
at -O0 we did not emit any DIE for external functions
but with optimization we emitted stubs.

2020-07-30  Richard Biener  <rguenther@suse.de>

	PR debug/96383
	* langhooks-def.h (lhd_finalize_early_debug): Declare.
	(LANG_HOOKS_FINALIZE_EARLY_DEBUG): Define.
	(LANG_HOOKS_INITIALIZER): Amend.
	* langhooks.c: Include cgraph.h and debug.h.
	(lhd_finalize_early_debug): Default implementation from
	former code in finalize_compilation_unit.
	* langhooks.h (lang_hooks::finalize_early_debug): Add.
	* cgraphunit.c (symbol_table::finalize_compilation_unit):
	Call the finalize_early_debug langhook.

gcc/c-family/
	* c-common.h (c_common_finalize_early_debug): Declare.
	* c-common.c: Include debug.h.
	(c_common_finalize_early_debug): finalize_early_debug langhook
	implementation generating debug for extern declarations.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_FINALIZE_EARLY_DEBUG):
	Define to c_common_finalize_early_debug.

gcc/cp/
	* cp-objcp-common.h (LANG_HOOKS_FINALIZE_EARLY_DEBUG):
	Define to c_common_finalize_early_debug.

gcc/testsuite/
	* gcc.dg/debug/dwarf2/pr96383-1.c: New testcase.
	* gcc.dg/debug/dwarf2/pr96383-2.c: Likewise.

libstdc++-v3/
	* testsuite/20_util/assume_aligned/3.cc: Use -g0.
2020-07-31 15:19:13 +02:00

35 lines
1.1 KiB
C++

// Copyright (C) 2018-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a -O2 -g0" }
// { dg-do compile { target c++2a } }
// { dg-final { scan-assembler-not "undefined" } }
#include <memory>
int* ptr();
extern "C" void undefined();
void
test01()
{
const std::size_t alignment = 4 * alignof(int);
int* p = std::assume_aligned<alignment>(ptr());
if ((std::uintptr_t)p % alignment)
undefined();
}