From 3767b2e4bebebeac612cc4c3210b43c31786a956 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 23 Aug 2017 12:11:03 +0000 Subject: [PATCH] re PR lto/81940 (internal compiler error: in dwarf2out_abstract_function, at dwarf2out.c:21613) 2017-08-23 Richard Biener PR lto/81940 * dwarf2out.c (dwarf2out_abstract_function): Handle LTO with -g0 at compile-time. * g++.dg/lto/pr81940_0.C: New testcase. From-SVN: r251306 --- gcc/ChangeLog | 6 ++++++ gcc/dwarf2out.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lto/pr81940_0.C | 5 +++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/lto/pr81940_0.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 37be75b1e4b..4d221a203a8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-08-23 Richard Biener + + PR lto/81940 + * dwarf2out.c (dwarf2out_abstract_function): Handle LTO with + -g0 at compile-time. + 2017-08-23 Tamar Christina PR middle-end/19706 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 0c339bd46f0..ba8d24bd590 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -21609,7 +21609,10 @@ dwarf2out_abstract_function (tree decl) return; old_die = lookup_decl_die (decl); - /* With early debug we always have an old DIE. */ + /* With early debug we always have an old DIE unless we are in LTO + and the user did not compile but only link with debug. */ + if (in_lto_p && ! old_die) + return; gcc_assert (old_die != NULL); if (get_AT (old_die, DW_AT_inline) || get_AT (old_die, DW_AT_abstract_origin)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 487d94bd06f..ff50edf6d38 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-23 Richard Biener + + PR lto/81940 + * g++.dg/lto/pr81940_0.C: New testcase. + 2017-08-23 Tamar Christina PR middle-end/19706 diff --git a/gcc/testsuite/g++.dg/lto/pr81940_0.C b/gcc/testsuite/g++.dg/lto/pr81940_0.C new file mode 100644 index 00000000000..4eba5fd34b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr81940_0.C @@ -0,0 +1,5 @@ +// { dg-lto-do link } +// { dg-lto-options { { -O -flto } } } +// { dg-extra-ld-options "-r -nostdlib -g" } + +int a, b = a; -- 2.30.2