* Go patch committed: do not propagate address-taken of slice element to slice
@ 2017-12-22 16:43 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2017-12-22 16:43 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
This patch by Cherry Zhang fixes the Go frontend to 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.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed
to mainline.
Ian
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1491 bytes --]
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 255976)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-83fc0e440b8c151edc5b1c67006257aad522ca04
+9b9bece388d1bacdc9d1d0024e722ffe449d221d
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc (revision 255976)
+++ gcc/go/gofrontend/expressions.cc (working copy)
@@ -10871,6 +10871,14 @@ Array_index_expression::do_is_addressabl
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.
Bexpression*
Index: gcc/go/gofrontend/expressions.h
===================================================================
--- gcc/go/gofrontend/expressions.h (revision 255976)
+++ gcc/go/gofrontend/expressions.h (working copy)
@@ -2896,8 +2896,7 @@ class Array_index_expression : public Ex
do_is_addressable() const;
void
- do_address_taken(bool escapes)
- { this->array_->address_taken(escapes); }
+ do_address_taken(bool escapes);
void
do_issue_nil_check()
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-12-22 16:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22 16:43 Go patch committed: do not propagate address-taken of slice element to slice Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).