Commit d7b24d55 by Ian Lance Taylor

compiler: do not propagate address-taken of a slice element to the slice

    
    Array_index_expression may be used for indexing/slicing array or
    slice. If a slice element is address taken, the slice itself is
    not necessarily address taken. Only propagate address-taken for
    arrays.
    
    Reviewed-on: https://go-review.googlesource.com/83877

From-SVN: r255977
parent bb14e19c
83fc0e440b8c151edc5b1c67006257aad522ca04 9b9bece388d1bacdc9d1d0024e722ffe449d221d
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.
...@@ -10871,6 +10871,14 @@ Array_index_expression::do_is_addressable() const ...@@ -10871,6 +10871,14 @@ Array_index_expression::do_is_addressable() const
return this->array_->is_addressable(); return this->array_->is_addressable();
} }
void
Array_index_expression::do_address_taken(bool escapes)
{
// In &x[0], if x is a slice, then x's address is not taken.
if (!this->array_->type()->is_slice_type())
this->array_->address_taken(escapes);
}
// Get the backend representation for an array index. // Get the backend representation for an array index.
Bexpression* Bexpression*
......
...@@ -2896,8 +2896,7 @@ class Array_index_expression : public Expression ...@@ -2896,8 +2896,7 @@ class Array_index_expression : public Expression
do_is_addressable() const; do_is_addressable() const;
void void
do_address_taken(bool escapes) do_address_taken(bool escapes);
{ this->array_->address_taken(escapes); }
void void
do_issue_nil_check() do_issue_nil_check()
......
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