GCC 9 Patch committed: Don't inline numeric expressions with named types

Message ID CAOyqgcX0M41qekVyPmCd67MD=2++LtKPeeXSfwO=2rWAZaKfdg@mail.gmail.com
State New
Headers show
Series
  • GCC 9 Patch committed: Don't inline numeric expressions with named types
Related show

Commit Message

Ian Lance Taylor Oct. 25, 2019, 7:10 p.m.
In the gofrontend we've encountered problems with numeric expressions
that have named types, as shown at https://golang.org/issue/34577.
Those problems are fixed on trunk, but the fixes there rely on other
machinery that has been added since the GCC 9 branch.  This patch
fixes the same problems on GCC 9 branch, but in this case by simply
not inlining functions that use this case.  This fixes
https://golang.org/issue/35154.  Bootstrapped and ran Go testsuite.
Committed to GCC 9 branch.

Ian

Patch

Index: expressions.cc
===================================================================
--- expressions.cc	(revision 271636)
+++ expressions.cc	(working copy)
@@ -2036,7 +2036,11 @@  class Integer_expression : public Expres
 
   int
   do_inlining_cost() const
-  { return 1; }
+  {
+    if (this->type_ != NULL && this->type_->named_type() != NULL)
+      return 0x100000;
+    return 1; 
+  }
 
   void
   do_export(Export_function_body*) const;
@@ -2451,7 +2455,11 @@  class Float_expression : public Expressi
 
   int
   do_inlining_cost() const
-  { return 1; }
+  {
+    if (this->type_ != NULL && this->type_->named_type() != NULL)
+      return 0x100000;
+    return 1;
+  }
 
   void
   do_export(Export_function_body*) const;
@@ -2664,7 +2672,11 @@  class Complex_expression : public Expres
 
   int
   do_inlining_cost() const
-  { return 2; }
+  {
+    if (this->type_ != NULL && this->type_->named_type() != NULL)
+      return 0x100000;
+    return 2;
+  }
 
   void
   do_export(Export_function_body*) const;