~angelsl/ubuntu/wily/gcc-5/mips-cross

« back to all changes in this revision

Viewing changes to debian/patches/go-escape-analysis5.diff

  • Committer: angelsl
  • Date: 2015-10-30 03:30:35 UTC
  • Revision ID: angelsl-20151030033035-rmug41zm8hyjgisg
Original import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# DP: gccgo: escape: Analyze binary expressions.
 
2
 
 
3
Binary expressions might contain function calls that cause an object
 
4
to escape.  Previously, there were not analyzed.
 
5
 
 
6
Index: b/src/gcc/go/gofrontend/escape.cc
 
7
===================================================================
 
8
--- a/src/gcc/go/gofrontend/escape.cc
 
9
+++ b/src/gcc/go/gofrontend/escape.cc
 
10
@@ -453,6 +453,11 @@ class Build_connection_graphs : public T
 
11
   void
 
12
   handle_composite_literal(Named_object* object, Expression* expr);
 
13
 
 
14
+  // Handle analysis of the left and right operands of a binary expression
 
15
+  // with respect to OBJECT.
 
16
+  void
 
17
+  handle_binary(Named_object* object, Expression* expr);
 
18
+
 
19
   // Resolve the outermost named object of EXPR if there is one.
 
20
   Named_object*
 
21
   resolve_var_reference(Expression* expr);
 
22
@@ -931,6 +936,31 @@ Build_connection_graphs::handle_composit
 
23
     }
 
24
 }
 
25
 
 
26
+// Given an OBJECT reference in a binary expression E, analyze the left and
 
27
+// right operands for possible edges.
 
28
+
 
29
+void
 
30
+Build_connection_graphs::handle_binary(Named_object* object, Expression* e)
 
31
+{
 
32
+  Binary_expression* be = e->binary_expression();
 
33
+  go_assert(be != NULL);
 
34
+  Expression* left = be->left();
 
35
+  Expression* right = be->right();
 
36
+
 
37
+  if (left->call_result_expression() != NULL)
 
38
+    left = left->call_result_expression()->call();
 
39
+  if (left->call_expression() != NULL)
 
40
+    this->handle_call(object, left);
 
41
+  else if (left->binary_expression() != NULL)
 
42
+    this->handle_binary(object, left);
 
43
+  if (right->call_result_expression() != NULL)
 
44
+    right = right->call_result_expression()->call();
 
45
+  if (right->call_expression() != NULL)
 
46
+    this->handle_call(object, right);
 
47
+  else if (right->binary_expression() != NULL)
 
48
+    this->handle_binary(object, right);
 
49
+}
 
50
+
 
51
 // Create connection nodes for each variable in a called function.
 
52
 
 
53
 int
 
54
@@ -1024,8 +1054,6 @@ Build_connection_graphs::variable(Named_
 
55
                 || rhs_no != var)
 
56
                break;
 
57
 
 
58
-             var_node->connection_node()->set_escape_state(Node::ESCAPE_ARG);
 
59
-
 
60
              Node* def_node = this->gogo_->add_connection_node(lhs_no);
 
61
              def_node->add_edge(var_node);
 
62
            }
 
63
@@ -1075,20 +1103,7 @@ Build_connection_graphs::variable(Named_
 
64
              if (cond->call_expression() != NULL)
 
65
                this->handle_call(var, cond);
 
66
              else if (cond->binary_expression() != NULL)
 
67
-               {
 
68
-                 Binary_expression* comp = cond->binary_expression();
 
69
-                 Expression* left = comp->left();
 
70
-                 Expression* right = comp->right();
 
71
-
 
72
-                 if (left->call_result_expression() != NULL)
 
73
-                   left = left->call_result_expression()->call();
 
74
-                 if (left->call_expression() != NULL)
 
75
-                   this->handle_call(var, left);
 
76
-                 if (right->call_result_expression() != NULL)
 
77
-                   right = right->call_result_expression()->call();
 
78
-                 if (right->call_expression() != NULL)
 
79
-                   this->handle_call(var, right);
 
80
-               }
 
81
+               this->handle_binary(var, cond);
 
82
            }
 
83
            break;
 
84
 
 
85
@@ -1117,6 +1132,8 @@ Build_connection_graphs::variable(Named_
 
86
                init = init->call_result_expression()->call();
 
87
              if (init->call_expression() != NULL)
 
88
                this->handle_call(var, init);
 
89
+             else if (init->binary_expression() != NULL)
 
90
+               this->handle_binary(var, init);
 
91
            }
 
92
            break;
 
93