aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-11-18 10:57:47 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-11-18 10:57:47 +0100
commit4f517dce47bb98269a4954438b2295dc93510d86 (patch)
treeeefe8ef212ec14999e70ff657eec5182204cd34f
parentb25833451bbe9b8a2194598b026cea071f4e9e65 (diff)
downloadgcc-4f517dce47bb98269a4954438b2295dc93510d86.zip
gcc-4f517dce47bb98269a4954438b2295dc93510d86.tar.gz
gcc-4f517dce47bb98269a4954438b2295dc93510d86.tar.bz2
dwarf2out.c (loc_list_from_tree): Don't call rtl_for_decl_location unnecessarily.
* 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. From-SVN: r154285
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/dwarf2out.c31
2 files changed, 32 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3ec03fc..c14d3c3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2009-11-18 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.
+
PR c++/3187
* cgraph.h (struct cgraph_node): Add same_body and same_body_alias
fields.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2ebe0ae..3db2092 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -14309,13 +14309,17 @@ loc_list_from_tree (tree loc, int want_address)
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;
@@ -15605,6 +15609,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;
}