From 60478b9caf9da70dc1301c863bb7c26a1ab5da9f Mon Sep 17 00:00:00 2001
From: Dehao Chen <dehao@google.com>
Date: Mon, 24 Sep 2012 20:50:46 +0000
Subject: [PATCH] tree-cfg.c (move_stmt_op): Reset the expr block only when
 necessary.

2012-09-24  Dehao Chen  <dehao@google.com>

	* tree-cfg.c (move_stmt_op): Reset the expr block only
	when necessary.
	(move_block_to_fn): Reset the edge's goto block even
	when the goto locus is unknown.

From-SVN: r191680
---
 gcc/ChangeLog  | 7 +++++++
 gcc/tree-cfg.c | 6 ++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 276feadea13a..36a918635b98 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2012-09-24  Dehao Chen  <dehao@google.com>
+
+	* tree-cfg.c (move_stmt_op): Reset the expr block only
+	when necessary.
+	(move_block_to_fn): Reset the edge's goto block even
+	when the goto locus is unknown.
+
 2012-09-24  Lawrence Crowl  <crowl@google.com>
 
 	* double-int.h (double_int::from_pair): New.
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index eea9a5cf92fd..774e74f2a545 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6013,7 +6013,9 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
 
   if (EXPR_P (t))
     {
-      if (TREE_BLOCK (t))
+      if (TREE_BLOCK (t) == p->orig_block
+	  || (p->orig_block == NULL_TREE
+	  && TREE_BLOCK (t) == NULL_TREE))
 	TREE_SET_BLOCK (t, p->new_block);
     }
   else if (DECL_P (t) || TREE_CODE (t) == SSA_NAME)
@@ -6315,7 +6317,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
     }
 
   FOR_EACH_EDGE (e, ei, bb->succs)
-    if (!IS_UNKNOWN_LOCATION (e->goto_locus))
+    if (e->goto_locus != UNKNOWN_LOCATION)
       {
 	tree block = LOCATION_BLOCK (e->goto_locus);
 	if (d->orig_block == NULL_TREE
-- 
GitLab