On 09.01.17 12:25, Jakub Jelinek wrote:
On Mon, Jan 09, 2017 at 11:53:38AM +0100, Richard Biener wrote:
Ok, attached the part I bootstrapped successfully on amd64-*-freebsd12 and
aarch64-*-freebsd12. From the amd64 run you'll find some test results at the
usual place. The aarch64 run takes some more time.
I hope I got it right this time :)
What do you think?
Looks good to me with the added comment to dwarf2out_late_global_decl
exchanged to the one on trunk.
The formatting is completely wrong.
Lines indented e.g. by 7 spaces (or tab + 1/3 space(s)),
/* comment inside of { block starting in the same column as {
(should be 2 columns to the right), && ! not aligned below VAR_P,
or indenting by 3 columns instead of 2.
Hehe, yep. This time done with emacs ;)
Here the hopefully final patch with proper ChangeLog and formatting fixed.
Ok to apply?
Thanks,
Andreas
2017-01-09 Andreas Tobler <andre...@gcc.gnu.org>
Backport from mainline
2016-09-19 Richard Biener <rguent...@suse.de>
* dwarf2out.c (dwarf2out_late_global_decl): When being during the
early debug phase do not add locations but only const value
attributes.
Backport from mainline
2016-10-20 Richard Biener <rguent...@suse.de>
* cgraphunit.c (analyze_functions): Set node->definition to
false to signal symbol removal to debug_hooks->late_global_decl.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 244100)
+++ gcc/dwarf2out.c (working copy)
@@ -23752,7 +23752,16 @@
{
dw_die_ref die = lookup_decl_die (decl);
if (die)
- add_location_or_const_value_attribute (die, decl, false);
+ {
+ /* We get called via the symtab code invoking late_global_decl
+ for symbols that are optimized out. Do not add locations
+ for those. */
+ varpool_node *node = varpool_node::get (decl);
+ if (! node || ! node->definition)
+ tree_add_const_value_attribute_for_decl (die, decl);
+ else
+ add_location_or_const_value_attribute (die, decl, false);
+ }
}
}
Index: gcc/cgraphunit.c
===================================================================
--- gcc/cgraphunit.c (revision 244100)
+++ gcc/cgraphunit.c (working copy)
@@ -1193,8 +1193,16 @@
at looking at optimized away DECLs, since
late_global_decl will subsequently be called from the
contents of the now pruned symbol table. */
- if (!decl_function_context (node->decl))
- (*debug_hooks->late_global_decl) (node->decl);
+ if (VAR_P (node->decl)
+ && !decl_function_context (node->decl))
+ {
+ /* We are reclaiming totally unreachable code and variables
+ so they effectively appear as readonly. Show that to
+ the debug machinery. */
+ TREE_READONLY (node->decl) = 1;
+ node->definition = false;
+ (*debug_hooks->late_global_decl) (node->decl);
+ }
node->remove ();
continue;