// 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_);
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);
// 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
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
// 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_;
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.
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.
// 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