This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto][patch] Avoid another case of local variables reachable from global trees


The attached patch fixes:
---------------------------------------
static bool f(const int *);
static int t1[2][2];
static int t2[2][2];
static int t3[2][2];
static int t4[2][2] ;
static int t5[2][2];
static int t6[2][2];
void g() {
  const int (*table[])[2] = {
    t1, t2, t3, t4, t5, t6 };
  for (unsigned i = 0; i < 5; ++i) {
    f((int *)table[i]);
  }
}
------------------------------------

When compiling for a pentium4 we replace "table" with a static
variable and the debug information from that static variable points
back to the local one.

OK for LTO if it bootstraps and tests are OK?


2008-07-02  Rafael Espindola  <espindola@google.com>

	* tree.c (reset_lang_specific): Remove local VAR_DECLs from
	DECL_DEBUG_EXPR of other VAR_DECLs.

Cheers,
--
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047
diff --git a/gcc/tree.c b/gcc/tree.c
index 47db050..0baf4f5 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3885,7 +3885,14 @@ reset_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED)
 	  DECL_SIZE_UNIT (decl) = NULL_TREE;
 	  DECL_SIZE (decl) = NULL_TREE;
 	}
-  }
+    }
+  if (TREE_CODE (decl) == VAR_DECL)
+    {
+      tree expr = DECL_DEBUG_EXPR (decl);
+      if (expr && TREE_CODE (expr) == VAR_DECL &&
+	  !TREE_STATIC (expr) && !DECL_EXTERNAL (expr))
+	SET_DECL_DEBUG_EXPR (decl, NULL_TREE);
+    }
   return 1;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]