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