re PR lto/56295 (Missed optimization with LTO)
authorRichard Biener <rguenther@suse.de>
Wed, 13 Feb 2013 13:31:18 +0000 (13:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 13 Feb 2013 13:31:18 +0000 (13:31 +0000)
2013-02-13  Richard Biener  <rguenther@suse.de>

PR lto/56295
* gimple-streamer-out.c (output_gimple_stmt): Undo wrapping
globals in MEM_REFs.

From-SVN: r196013

gcc/ChangeLog
gcc/gimple-streamer-out.c

index 38339d0def760d64d15c62eb1a03972d4e883038..334f8fedccfe580d6c5557f74d3551915877a27b 100644 (file)
@@ -1,3 +1,9 @@
+2013-02-13  Richard Biener  <rguenther@suse.de>
+
+       PR lto/56295
+       * gimple-streamer-out.c (output_gimple_stmt): Undo wrapping
+       globals in MEM_REFs.
+
 2013-02-13  Richard Biener  <rguenther@suse.de>
 
        * loop-init.c (loop_optimizer_init): Clear loop state when
index 24ab0ed718176ab1d31acb1798d85eb946d8ddfa..adf230ed93acffc8debc56c125ac835c48edd6eb 100644 (file)
@@ -116,13 +116,14 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       for (i = 0; i < gimple_num_ops (stmt); i++)
        {
          tree op = gimple_op (stmt, i);
+         tree *basep = NULL;
          /* Wrap all uses of non-automatic variables inside MEM_REFs
             so that we do not have to deal with type mismatches on
             merged symbols during IL read in.  The first operand
             of GIMPLE_DEBUG must be a decl, not MEM_REF, though.  */
          if (op && (i || !is_gimple_debug (stmt)))
            {
-             tree *basep = &op;
+             basep = &op;
              while (handled_component_p (*basep))
                basep = &TREE_OPERAND (*basep, 0);
              if (TREE_CODE (*basep) == VAR_DECL
@@ -136,8 +137,13 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
                                                  (TREE_TYPE (*basep)), 0));
                  TREE_THIS_VOLATILE (*basep) = volatilep;
                }
+             else
+               basep = NULL;
            }
          stream_write_tree (ob, op, true);
+         /* Restore the original base if we wrapped it inside a MEM_REF.  */
+         if (basep)
+           *basep = TREE_OPERAND (TREE_OPERAND (*basep, 0), 0);
        }
       if (is_gimple_call (stmt))
        {