diff mbox series

Go patch committed: Don't set ptrmask bit for pointer to notinheap type

Message ID CAOyqgcVhmT3Vm9=v2V_0E++QLdcEosqDuUc_XMm65G8mANg4aw@mail.gmail.com
State New
Headers show
Series Go patch committed: Don't set ptrmask bit for pointer to notinheap type | expand

Commit Message

Ian Lance Taylor Feb. 13, 2022, 6:54 p.m. UTC
This patch fixes the Go frontend to not set a bit in the
garbage-collection ptrmask bit for a pointer to notinheap type.  This
is a follow-up to
https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590150.html.
The test case for this is https://go.dev/cl/385454.  Bootstrapped and
ran Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
14d5dc6e03cff4ecf46cd29dbceb32eea76467ef
diff mbox series

Patch

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 4e6bac7b7d5..02a6e1d661d 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@ 
-47380f733ca932384e59492d2f04374edd8ec95e
+7f8fee099d6de4a5a857765e0ddfae356ead554c
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index ee3467666d8..8267f1565ce 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -2816,6 +2816,9 @@  class Ptrmask
 void
 Ptrmask::set_from(Gogo* gogo, Type* type, int64_t ptrsize, int64_t offset)
 {
+  if (!type->has_pointer())
+    return;
+
   switch (type->base()->classification())
     {
     default:
@@ -2858,9 +2861,6 @@  Ptrmask::set_from(Gogo* gogo, Type* type, int64_t ptrsize, int64_t offset)
 
     case Type::TYPE_STRUCT:
       {
-	if (!type->has_pointer())
-	  return;
-
 	const Struct_field_list* fields = type->struct_type()->fields();
 	int64_t soffset = 0;
 	for (Struct_field_list::const_iterator pf = fields->begin();
@@ -2898,9 +2898,6 @@  Ptrmask::set_from(Gogo* gogo, Type* type, int64_t ptrsize, int64_t offset)
 	}
       else
 	{
-	  if (!type->has_pointer())
-	    return;
-
 	  int64_t len;
 	  if (!type->array_type()->int_length(&len))
 	    {