Patchwork Fix PR53195, properly add referenced vars during IPA-CP

login
register
mail settings
Submitter Richard Guenther
Date May 7, 2012, 12:56 p.m.
Message ID <Pine.LNX.4.64.1205071455180.23071@jbgna.fhfr.qr>
Download mbox | patch
Permalink /patch/157304/
State New
Headers show

Comments

Richard Guenther - May 7, 2012, 12:56 p.m.
We fail to add referenced vars when inline copies are instantiated
from clones created from IPA-CP.  That later leads to ICEs in
remove-unused-locals because var_ann has not been allocated.

Bootstrapped and tested on x86_64-unknown-linux-gnu, LTO bootstrapped.

Applied to trunk and branch.

Richard.

2012-05-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/53195
	* tree-inline.c (setup_one_parameter): Properly add referenced
	vars from the parameters new known value.

Patch

Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 187228)
+++ gcc/tree-inline.c	(working copy)
@@ -2607,6 +2607,17 @@  setup_one_parameter (copy_body_data *id,
   /* Make gimplifier happy about this variable.  */
   DECL_SEEN_IN_BIND_EXPR_P (var) = 1;
 
+  /* We are eventually using the value - make sure all variables
+     referenced therein are properly recorded.  */
+  if (value
+      && gimple_in_ssa_p (cfun)
+      && TREE_CODE (value) == ADDR_EXPR)
+    {
+      tree base = get_base_address (TREE_OPERAND (value, 0));
+      if (base && TREE_CODE (base) == VAR_DECL)
+	add_referenced_var (base);
+    }
+
   /* If the parameter is never assigned to, has no SSA_NAMEs created,
      we would not need to create a new variable here at all, if it
      weren't for debug info.  Still, we can just use the argument