* [PATCH] Try harder to emit DW_AT_location for TLS vars
@ 2009-11-09 13:40 Jakub Jelinek
2009-11-10 15:26 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2009-11-09 13:40 UTC (permalink / raw)
To: gcc-patches
Hi!
Now that resolve_addr in dwarf2out nukes at the end expressions
referencing SYMBOL_REFs not emitted to assembly we can do better for
debuginfo of TLS VAR_DECLs that don't have DECL_RTL set yet
(e.g. if a Fortran TLS common is referenced just in an OpenMP parallel
region, in the parent fn it might not have DECL_RTL set yet).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2009-11-09 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.c (loc_list_from_tree): For TLS vars try harder to get
rtl for DW_OP_GNU_push_tls_address addr.
--- gcc/dwarf2out.c.jj 2009-11-04 08:16:04.000000000 +0100
+++ gcc/dwarf2out.c 2009-11-06 16:11:47.000000000 +0100
@@ -14281,7 +14281,26 @@ loc_list_from_tree (tree loc, int want_a
rtl = rtl_for_decl_location (loc);
if (rtl == NULL_RTX)
- return 0;
+ {
+ if (DECL_EXTERNAL (loc))
+ return 0;
+
+ gcc_assert (TREE_STATIC (loc)
+ && DECL_NAME (loc)
+ && !DECL_HARD_REGISTER (loc)
+ && DECL_MODE (loc) != VOIDmode);
+
+ /* Try harder to get a rtl. If this symbol
+ ends up not being emitted in the current CU,
+ resolve_addr will remove the expression
+ referencing it. */
+ rtl = DECL_RTL (loc);
+ SET_DECL_RTL (loc, NULL);
+ if (!MEM_P (rtl)
+ || GET_CODE (XEXP (rtl, 0)) != SYMBOL_REF
+ || SYMBOL_REF_DECL (XEXP (rtl, 0)) != loc)
+ return 0;
+ }
if (!MEM_P (rtl))
return 0;
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Try harder to emit DW_AT_location for TLS vars
2009-11-09 13:40 [PATCH] Try harder to emit DW_AT_location for TLS vars Jakub Jelinek
@ 2009-11-10 15:26 ` Ian Lance Taylor
2009-11-11 16:26 ` [PATCH] Try harder to emit DW_AT_location (take 2) Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2009-11-10 15:26 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
Jakub Jelinek <jakub@redhat.com> writes:
> Now that resolve_addr in dwarf2out nukes at the end expressions
> referencing SYMBOL_REFs not emitted to assembly we can do better for
> debuginfo of TLS VAR_DECLs that don't have DECL_RTL set yet
> (e.g. if a Fortran TLS common is referenced just in an OpenMP parallel
> region, in the parent fn it might not have DECL_RTL set yet).
What is special about TLS variables that makes them subject to this
problem? Why not do something like this in rtl_for_decl_location?
Calling DECL_RTL and then SET_DECL_RTL is rather awkward and requires
a comment.
Ian
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2009-11-09 Jakub Jelinek <jakub@redhat.com>
>
> * dwarf2out.c (loc_list_from_tree): For TLS vars try harder to get
> rtl for DW_OP_GNU_push_tls_address addr.
>
> --- gcc/dwarf2out.c.jj 2009-11-04 08:16:04.000000000 +0100
> +++ gcc/dwarf2out.c 2009-11-06 16:11:47.000000000 +0100
> @@ -14281,7 +14281,26 @@ loc_list_from_tree (tree loc, int want_a
>
> rtl = rtl_for_decl_location (loc);
> if (rtl == NULL_RTX)
> - return 0;
> + {
> + if (DECL_EXTERNAL (loc))
> + return 0;
> +
> + gcc_assert (TREE_STATIC (loc)
> + && DECL_NAME (loc)
> + && !DECL_HARD_REGISTER (loc)
> + && DECL_MODE (loc) != VOIDmode);
> +
> + /* Try harder to get a rtl. If this symbol
> + ends up not being emitted in the current CU,
> + resolve_addr will remove the expression
> + referencing it. */
> + rtl = DECL_RTL (loc);
> + SET_DECL_RTL (loc, NULL);
> + if (!MEM_P (rtl)
> + || GET_CODE (XEXP (rtl, 0)) != SYMBOL_REF
> + || SYMBOL_REF_DECL (XEXP (rtl, 0)) != loc)
> + return 0;
> + }
>
> if (!MEM_P (rtl))
> return 0;
>
> Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Try harder to emit DW_AT_location (take 2)
2009-11-10 15:26 ` Ian Lance Taylor
@ 2009-11-11 16:26 ` Jakub Jelinek
2009-11-13 19:35 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2009-11-11 16:26 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-patches
On Tue, Nov 10, 2009 at 07:20:07AM -0800, Ian Lance Taylor wrote:
> What is special about TLS variables that makes them subject to this
> problem? Why not do something like this in rtl_for_decl_location?
Nothing, just I thought at least in some cases rtl_for_decl_location
would try to do that unnecessarily (e.g. when just checking if the RTL
is CONST_STRING or CONST).
Anyway, if you prefer it that way, here is a patch that has been also
bootstrapped/regtested on x86_64-linux and i686-linux.
2009-11-11 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.c (loc_list_from_tree): Don't call rtl_for_decl_location
unnecessarily.
(rtl_for_decl_location): Try harder to get a rtl for TREE_STATIC vars.
--- gcc/dwarf2out.c.jj 2009-11-09 20:39:21.000000000 +0100
+++ gcc/dwarf2out.c 2009-11-11 15:13:34.000000000 +0100
@@ -14311,13 +14311,17 @@ loc_list_from_tree (tree loc, int want_a
case RESULT_DECL:
case FUNCTION_DECL:
{
- rtx rtl = rtl_for_decl_location (loc);
+ rtx rtl;
var_loc_list *loc_list = lookup_decl_loc (loc);
if (loc_list && loc_list->first
&& (list_ret = dw_loc_list (loc_list, loc, want_address)))
- have_address = want_address != 0;
- else if (rtl == NULL_RTX)
+ {
+ have_address = want_address != 0;
+ break;
+ }
+ rtl = rtl_for_decl_location (loc);
+ if (rtl == NULL_RTX)
{
expansion_failed (loc, NULL_RTX, "DECL has no RTL");
return 0;
@@ -15607,6 +15611,27 @@ rtl_for_decl_location (tree decl)
if (rtl)
rtl = avoid_constant_pool_reference (rtl);
+ /* Try harder to get a rtl. If this symbol ends up not being emitted
+ in the current CU, resolve_addr will remove the expression referencing
+ it. */
+ if (rtl == NULL_RTX
+ && TREE_CODE (decl) == VAR_DECL
+ && !DECL_EXTERNAL (decl)
+ && TREE_STATIC (decl)
+ && DECL_NAME (decl)
+ && !DECL_HARD_REGISTER (decl)
+ && DECL_MODE (decl) != VOIDmode)
+ {
+ rtl = DECL_RTL (decl);
+ /* Reset DECL_RTL back, as various parts of the compiler expects
+ DECL_RTL set meaning it is actually going to be output. */
+ SET_DECL_RTL (decl, NULL);
+ if (!MEM_P (rtl)
+ || GET_CODE (XEXP (rtl, 0)) != SYMBOL_REF
+ || SYMBOL_REF_DECL (XEXP (rtl, 0)) != decl)
+ rtl = NULL_RTX;
+ }
+
return rtl;
}
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Try harder to emit DW_AT_location (take 2)
2009-11-11 16:26 ` [PATCH] Try harder to emit DW_AT_location (take 2) Jakub Jelinek
@ 2009-11-13 19:35 ` Richard Henderson
0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2009-11-13 19:35 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ian Lance Taylor, gcc-patches
On 11/11/2009 08:01 AM, Jakub Jelinek wrote:
> * dwarf2out.c (loc_list_from_tree): Don't call rtl_for_decl_location
> unnecessarily.
> (rtl_for_decl_location): Try harder to get a rtl for TREE_STATIC vars.
Ok.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-13 19:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-09 13:40 [PATCH] Try harder to emit DW_AT_location for TLS vars Jakub Jelinek
2009-11-10 15:26 ` Ian Lance Taylor
2009-11-11 16:26 ` [PATCH] Try harder to emit DW_AT_location (take 2) Jakub Jelinek
2009-11-13 19:35 ` Richard Henderson
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).