Commit 03f0fa95 by Ian Lance Taylor

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
parent 3a03bffd
416baf55e4890acab244470f6457372987a17a68 d9a30434440469c640a120fe7132057f5644d38c
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -3936,24 +3936,12 @@ Unary_expression::check_operand_address_taken(Gogo*) ...@@ -3936,24 +3936,12 @@ Unary_expression::check_operand_address_taken(Gogo*)
// If this->escapes_ is false at this point, then it was set to // 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 // 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 // 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 // set it to false based on the escape analysis pass.
// escape. if (this->escapes_)
{
Node* n = Node::make_node(this); Node* n = Node::make_node(this);
if ((n->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE)) if ((n->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE))
this->escapes_ = false; 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)
{
if (var->is_variable())
this->escapes_ = var->var_value()->escapes();
if (var->is_result_variable())
this->escapes_ = var->result_var_value()->escapes();
} }
this->expr_->address_taken(this->escapes_); this->expr_->address_taken(this->escapes_);
......
...@@ -6939,8 +6939,7 @@ Variable::Variable(Type* type, Expression* init, bool is_global, ...@@ -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_init_tuple_(false), type_from_range_index_(false),
type_from_range_value_(false), type_from_chan_element_(false), type_from_range_value_(false), type_from_chan_element_(false),
is_type_switch_var_(false), determined_type_(false), is_type_switch_var_(false), determined_type_(false),
in_unique_section_(false), escapes_(true), in_unique_section_(false), toplevel_decl_(NULL)
toplevel_decl_(NULL)
{ {
go_assert(type != NULL || init != NULL); go_assert(type != NULL || init != NULL);
go_assert(!is_parameter || init == NULL); go_assert(!is_parameter || init == NULL);
......
...@@ -1863,11 +1863,7 @@ class Variable ...@@ -1863,11 +1863,7 @@ class Variable
// Whether this variable should live in the heap. // Whether this variable should live in the heap.
bool bool
is_in_heap() const is_in_heap() const
{ { return this->is_address_taken_ && !this->is_global_; }
return this->is_address_taken_
&& this->escapes_
&& !this->is_global_;
}
// Note that something takes the address of this variable. // Note that something takes the address of this variable.
void void
...@@ -1885,16 +1881,6 @@ class Variable ...@@ -1885,16 +1881,6 @@ class Variable
set_non_escaping_address_taken() set_non_escaping_address_taken()
{ this->is_non_escaping_address_taken_ = true; } { 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. // Get the source location of the variable's declaration.
Location Location
location() const location() const
...@@ -2117,9 +2103,6 @@ class Variable ...@@ -2117,9 +2103,6 @@ class Variable
// True if this variable should be put in a unique section. This is // True if this variable should be put in a unique section. This is
// used for field tracking. // used for field tracking.
bool in_unique_section_ : 1; 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 // The top-level declaration for this variable. Only used for local
// variables. Must be a Temporary_statement if not NULL. // variables. Must be a Temporary_statement if not NULL.
Statement* toplevel_decl_; Statement* toplevel_decl_;
...@@ -2135,7 +2118,7 @@ class Result_variable ...@@ -2135,7 +2118,7 @@ class Result_variable
Location location) Location location)
: type_(type), function_(function), index_(index), location_(location), : type_(type), function_(function), index_(index), location_(location),
backend_(NULL), is_address_taken_(false), 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. // Get the type of the result variable.
...@@ -2179,23 +2162,10 @@ class Result_variable ...@@ -2179,23 +2162,10 @@ class Result_variable
set_non_escaping_address_taken() set_non_escaping_address_taken()
{ this->is_non_escaping_address_taken_ = true; } { 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. // Whether this variable should live in the heap.
bool bool
is_in_heap() const is_in_heap() const
{ { return this->is_address_taken_; }
return this->is_address_taken_
&& this->escapes_;
}
// Set the function. This is used when cloning functions which call // Set the function. This is used when cloning functions which call
// recover. // recover.
...@@ -2223,9 +2193,6 @@ class Result_variable ...@@ -2223,9 +2193,6 @@ class Result_variable
// Whether something takes the address of this variable such that // Whether something takes the address of this variable such that
// the address does not escape the function. // the address does not escape the function.
bool is_non_escaping_address_taken_; 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 // The value we keep for a named constant. This lets us hold a type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment