This patch to the Go frontend removes the escapes_ field from Variable and Result_variable. The fields were set to true initially and never set to false. These were left over from an earlier attempt at escape analysis. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 267435) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -416baf55e4890acab244470f6457372987a17a68 +d9a30434440469c640a120fe7132057f5644d38c The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 267433) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -3936,24 +3936,12 @@ Unary_expression::check_operand_address_ // If this->escapes_ is false at this point, then it was set to // false by an explicit call to set_does_not_escape, and the value // does not escape. If this->escapes_ is true, we may be able to - // set it to false if taking the address of a variable that does not - // escape. - Node* n = Node::make_node(this); - if ((n->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE)) - this->escapes_ = false; - - Named_object* var = NULL; - if (this->expr_->var_expression() != NULL) - var = this->expr_->var_expression()->named_object(); - else if (this->expr_->enclosed_var_expression() != NULL) - var = this->expr_->enclosed_var_expression()->variable(); - - if (this->escapes_ && var != NULL) + // set it to false based on the escape analysis pass. + if (this->escapes_) { - if (var->is_variable()) - this->escapes_ = var->var_value()->escapes(); - if (var->is_result_variable()) - this->escapes_ = var->result_var_value()->escapes(); + Node* n = Node::make_node(this); + if ((n->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE)) + this->escapes_ = false; } this->expr_->address_taken(this->escapes_); Index: gcc/go/gofrontend/gogo.cc =================================================================== --- gcc/go/gofrontend/gogo.cc (revision 267433) +++ gcc/go/gofrontend/gogo.cc (working copy) @@ -6939,8 +6939,7 @@ Variable::Variable(Type* type, Expressio type_from_init_tuple_(false), type_from_range_index_(false), type_from_range_value_(false), type_from_chan_element_(false), is_type_switch_var_(false), determined_type_(false), - in_unique_section_(false), escapes_(true), - toplevel_decl_(NULL) + in_unique_section_(false), toplevel_decl_(NULL) { go_assert(type != NULL || init != NULL); go_assert(!is_parameter || init == NULL); Index: gcc/go/gofrontend/gogo.h =================================================================== --- gcc/go/gofrontend/gogo.h (revision 267433) +++ gcc/go/gofrontend/gogo.h (working copy) @@ -1863,11 +1863,7 @@ class Variable // Whether this variable should live in the heap. bool is_in_heap() const - { - return this->is_address_taken_ - && this->escapes_ - && !this->is_global_; - } + { return this->is_address_taken_ && !this->is_global_; } // Note that something takes the address of this variable. void @@ -1885,16 +1881,6 @@ class Variable set_non_escaping_address_taken() { this->is_non_escaping_address_taken_ = true; } - // Return whether this variable escapes the function it is declared in. - bool - escapes() - { return this->escapes_; } - - // Note that this variable does not escape the function it is declared in. - void - set_does_not_escape() - { this->escapes_ = false; } - // Get the source location of the variable's declaration. Location location() const @@ -2117,9 +2103,6 @@ class Variable // True if this variable should be put in a unique section. This is // used for field tracking. bool in_unique_section_ : 1; - // Whether this variable escapes the function it is created in. This is - // true until shown otherwise. - bool escapes_ : 1; // The top-level declaration for this variable. Only used for local // variables. Must be a Temporary_statement if not NULL. Statement* toplevel_decl_; @@ -2135,7 +2118,7 @@ class Result_variable Location location) : type_(type), function_(function), index_(index), location_(location), backend_(NULL), is_address_taken_(false), - is_non_escaping_address_taken_(false), escapes_(true) + is_non_escaping_address_taken_(false) { } // Get the type of the result variable. @@ -2179,23 +2162,10 @@ class Result_variable set_non_escaping_address_taken() { this->is_non_escaping_address_taken_ = true; } - // Return whether this variable escapes the function it is declared in. - bool - escapes() - { return this->escapes_; } - - // Note that this variable does not escape the function it is declared in. - void - set_does_not_escape() - { this->escapes_ = false; } - // Whether this variable should live in the heap. bool is_in_heap() const - { - return this->is_address_taken_ - && this->escapes_; - } + { return this->is_address_taken_; } // Set the function. This is used when cloning functions which call // recover. @@ -2223,9 +2193,6 @@ class Result_variable // Whether something takes the address of this variable such that // the address does not escape the function. bool is_non_escaping_address_taken_; - // Whether this variable escapes the function it is created in. This is - // true until shown otherwise. - bool escapes_; }; // The value we keep for a named constant. This lets us hold a type