From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix missed debug PR77692
Date: Fri, 23 Sep 2016 13:02:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.11.1609231441580.26629@t29.fhfr.qr> (raw)
I am testing the following patch which re-instantiates behavior
to emit DW_AT_const_value attributes for optimized out non-readonly
global statics. Those are readonly by means of the ability to
remove them early (before any optimization such as removing stores
to write-only global vars). Before my change to make the
late_global_decl debug hook not go via
add_location_or_const_value_attribute but only
tree_add_const_value_attribute_for_decl during the early debug phase
the former function ran into rtl_for_decl_location doing
/* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time
constant,
and will have been substituted directly into all expressions that use
it.
C does not have such a concept, but C++ and other languages do. */
if (!rtl && TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
rtl = rtl_for_decl_init (DECL_INITIAL (decl), TREE_TYPE (decl));
where obviously at this point of the compilation no DECL_RTL was
created yet (the above code looks fishy to me --
tree_add_const_value_attribute_for_decl checks for TREE_READONLY on
the decl).
Anyway, bootstrapping and regtesting the following on
x86_64-unknown-linux-gnu (it makes gcc.dg/debug/dwarf2/const-2b.c PASS
again).
Comments welcome.
Richard.
2016-09-23 Richard Biener <rguenther@suse.de>
PR debug/77692
* cgraphunit.c (analyze_functions): Before early removing
global vars calls the late_global_decl debug handler mark
the variable as readonly.
Index: gcc/cgraphunit.c
===================================================================
--- gcc/cgraphunit.c (revision 240388)
+++ gcc/cgraphunit.c (working copy)
@@ -1194,8 +1194,15 @@ analyze_functions (bool first_time)
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 (TREE_CODE (node->decl) == VAR_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;
+ (*debug_hooks->late_global_decl) (node->decl);
+ }
node->remove ();
continue;
next reply other threads:[~2016-09-23 12:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 13:02 Richard Biener [this message]
2016-09-26 7:42 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.11.1609231441580.26629@t29.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).