This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Try harder to emit DW_AT_location for TLS vars
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 9 Nov 2009 14:32:15 +0100
- Subject: [PATCH] Try harder to emit DW_AT_location for TLS vars
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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