1
# DP: gccgo: escape: Analyze binary expressions.
3
Binary expressions might contain function calls that cause an object
4
to escape. Previously, there were not analyzed.
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
12
handle_composite_literal(Named_object* object, Expression* expr);
14
+ // Handle analysis of the left and right operands of a binary expression
15
+ // with respect to OBJECT.
17
+ handle_binary(Named_object* object, Expression* expr);
19
// Resolve the outermost named object of EXPR if there is one.
21
resolve_var_reference(Expression* expr);
22
@@ -931,6 +936,31 @@ Build_connection_graphs::handle_composit
26
+// Given an OBJECT reference in a binary expression E, analyze the left and
27
+// right operands for possible edges.
30
+Build_connection_graphs::handle_binary(Named_object* object, Expression* e)
32
+ Binary_expression* be = e->binary_expression();
33
+ go_assert(be != NULL);
34
+ Expression* left = be->left();
35
+ Expression* right = be->right();
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);
51
// Create connection nodes for each variable in a called function.
54
@@ -1024,8 +1054,6 @@ Build_connection_graphs::variable(Named_
58
- var_node->connection_node()->set_escape_state(Node::ESCAPE_ARG);
60
Node* def_node = this->gogo_->add_connection_node(lhs_no);
61
def_node->add_edge(var_node);
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)
68
- Binary_expression* comp = cond->binary_expression();
69
- Expression* left = comp->left();
70
- Expression* right = comp->right();
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);
81
+ this->handle_binary(var, cond);
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);