From 03f0fa9538a68a9e192a7e157b333b54eb72d5c8 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 28 Dec 2018 21:10:33 +0000 Subject: [PATCH] compiler: remove 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. Reviewed-on: https://go-review.googlesource.com/c/155750 From-SVN: r267455 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/expressions.cc | 22 ++++-------------- gcc/go/gofrontend/gogo.cc | 3 +-- gcc/go/gofrontend/gogo.h | 39 +++----------------------------- 4 files changed, 10 insertions(+), 56 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3dd5fb2154b..2552025d9de 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -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. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 7c464ce7f54..ef8a917c290 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -3936,24 +3936,12 @@ Unary_expression::check_operand_address_taken(Gogo*) // 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_); diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 5654e30849d..d0d6f3b3b54 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -6939,8 +6939,7 @@ Variable::Variable(Type* type, Expression* init, bool is_global, 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); diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index 0331ccacee3..be6048f98a4 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -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 -- 2.30.2