public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: put type descriptor initializers in .rodata
@ 2018-09-09 13:26 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2018-09-09 13:26 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 788 bytes --]

This patch to the Go frontend by Than McIntosh puts type descriptor
initializers in the .rodata section.  When creating type descriptor
variables, the frontend (specifically Type::make_type_descriptor_var)
invokes the immutable_struct() and immutable_struct_set_init() back
end methods, so as to insure that these items go into the .rodata
section of the generate object file.  The expression initializers for
these variables can contain nested subexpressions, however, and these
subexpressions were not always being placed into .rodata.  This patch
changes the backend-gen code for slice initializers to emit implicit
variables into .rodata if those initializers are part of a type
descriptor init.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1140 bytes --]

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 264163)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-da249ffd264154cc992e76ff03f91f700d3bf53e
+06e688ff6d829c8de3735e9f59b61b373afc596f
 
 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 264163)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -4453,7 +4453,8 @@ Unary_expression::do_get_backend(Transla
 	      // initialize the value once, so we can use this directly
 	      // rather than copying it.  In that case we can't make it
 	      // read-only, because the program is permitted to change it.
-	      copy_to_heap = context->function() != NULL;
+	      copy_to_heap = (context->function() != NULL
+                              || context->is_const());
 	    }
 	  std::string asm_name(go_selectively_encode_id(var_name));
 	  Bvariable* implicit =

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-09-09 13:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-09 13:26 Go patch committed: put type descriptor initializers in .rodata 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).