Go patch committed: put type descriptor initializers in .rodata

Message ID CAOyqgcX9ZZVCjieyzZOqcRUtcxZczsOTTTW0zV50RUG3WsjgKg@mail.gmail.com
State New
Headers show
Series
  • Go patch committed: put type descriptor initializers in .rodata
Related show

Commit Message

Ian Lance Taylor Sept. 9, 2018, 1:26 p.m.
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

Patch

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 =