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.
Change-Id: I1b8e8a1a27594df6c6fc7465d5244cdc676d2a0a
Reviewed-on: https://go-review.googlesource.com/c/155750
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/go/expressions.cc b/go/expressions.cc
index 7c464ce..ef8a917 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -3936,24 +3936,12 @@
// 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/go/gogo.cc b/go/gogo.cc
index 5654e30..d0d6f3b 100644
--- a/go/gogo.cc
+++ b/go/gogo.cc
@@ -6939,8 +6939,7 @@
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/go/gogo.h b/go/gogo.h
index 0331cca..be6048f 100644
--- a/go/gogo.h
+++ b/go/gogo.h
@@ -1863,11 +1863,7 @@
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
// 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