Data Recovery Services and Hardware Repair Services

2015-03-07 Thread Lance

We have made helping people our business. We only do data recovery, we do
it all day, every day - we have become the very best in this field. We have
seen all types of problems and solved nearly all of them!

Why we are here?
Data – Important assets of enterprises and individuals, is the key
element of great success. Virus Attack, Back-up failure, Hard Disk Drive
Crash, System Failure, Nature Disasters, Human Errors are one of the causes
of Data Loss, which might potentially cause million and billions loss of
profit. IntelliRecovery experts with their overwhelming experience,
state-of-the-art tools and deep knowledge provide finest and innovative
Data Recovery Solutions for all types of storage media and file systems in
case of data loss. We are dedicated to provide you unmatchable, updated and
quality data recovery services and we have enduring commitments to customer
satisfaction.

Nowadays, personal computer, mobile devices, networks, servers etc are so
popular and they have become something we can’t miss in our daily life.
This kind of digital platform can drive efficiency and convenience,
unfortunately there is a huge risk behind – Data loss. Hence,
IntelliRecovery team are here to recover and salvage lost data from
disaster stricken hard drives, computer workstations, laptops, e-mails,
smartphones, PDA's, iPods and portable storage media of every brand,
manufacturer, model and capacity.

What can we do?

   Hard disk data recovery
   RAID array data recovery
   Emergency data recovery
   USB flash drive data recovery
   Memory card data recovery

   Mobile phone data recovery
   Apple iPhone Passcode/PIN Removal
   Mobile Phone Spyware & Virus Detection
   NAS Data Recovery
   Data destruction
   Hard disk duplication
   Hard disk password removal

We believe in doing business in an honest, friendly and professional way.
We are always up front, honest and provide realistic time estimates, quotes
and believe in providing the best service possible. No data recovery
company can guarantee that they can recover your data (e.g if your disk
platter is scratched or data is overwritten) but we promise not to give up
until we recover your data or completely exhaust all possible options to
help you! If your data cannot be recovered for any reason, we'll give you
an honest explanation of the reason and assure you that we have done
everything in our power to try to help you.  In over 90% of cases, we can
recover data from hard disks and other data storage devices. We look
forward to helping you!

We also provide Mobile Phone Repair services for Iphone, Ipad, and we
specialize in repairing cell phones, smart phones, computers, laptops, game
consoles, cameras, mp3 players, and most any other electronic gadget you
can throw at us. We strive to create solutions where there weren’t any
before.

Best regards,
Lance
Email: drdatab...@tom.com



Re: [PATCH] libiberty: Use posix_spawn in pex-unix when available.

2023-10-02 Thread Ian Lance Taylor
On Fri, Sep 29, 2023 at 12:18 PM Brendan Shanks  wrote:
>
> +  #define ERR_ON_FAILURE(ret, func) \
> +do { if (ret) { *err = ret; *errmsg = func; goto exit; } else {} } while 
> (0)

Thanks, but please don't use a macro that changes control flow.

Ian


Re: [PATCH v2] libiberty: Use posix_spawn in pex-unix when available.

2023-10-03 Thread Ian Lance Taylor
On Tue, Oct 3, 2023 at 12:04 PM Brendan Shanks  wrote:
>
> +  ret = posix_spawnattr_init (&attr);
> +  if (ret) { *err = ret; *errmsg = "posix_spawnattr_init"; goto exit; }

Sorry, but let's keep the formatting used in the rest of the file.

if (ret != 0)
  {
*err = ret;
*errmsg = "posix_spawnattr_init";
goto exit;
  }



> +  if (in != STDIN_FILE_NO)
> +close (in);
> +  if (out != STDOUT_FILE_NO)
> +close (out);
> +  if (errdes != STDERR_FILE_NO)
> +close (errdes);

Not a big deal, but the other version of this function checks the
error result of close.

Ian


libgo patch committed: Check return value as well as error from waitid

2018-07-02 Thread Ian Lance Taylor
This libgo patch checks the return value as well as the error from
waitid.  https://gcc.gnu.org/PR86331 indicates that if a signal
handler runs it is possible for syscall.Syscall6 to return a non-zero
errno value even if no error occurs. That is a problem in general, but
this fix will let us work around the general problem for the specific
case of calling waitid.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to trunk, GCC 8 branch, and GCC 7
branch.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262312)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-e1fcce0aec27b1f50ac0e736f39f4c806c2a5baa
+94738979a3422e845acf358a766aabf8b9275d43
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/os/wait_waitid.go
===
--- libgo/go/os/wait_waitid.go  (revision 262312)
+++ libgo/go/os/wait_waitid.go  (working copy)
@@ -28,9 +28,12 @@ func (p *Process) blockUntilWaitable() (
// We don't care about the values it returns.
var siginfo [16]uint64
psig := &siginfo[0]
-   _, _, e := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), 
uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)
+   r, _, e := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), 
uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)
runtime.KeepAlive(p)
-   if e != 0 {
+   // Check r as well as e because syscall.Syscall6 currently
+   // just returns errno, and the SIGCHLD signal handler may
+   // change errno. See https://gcc.gnu.org/PR86331.
+   if r != 0 && e != 0 {
// waitid has been available since Linux 2.6.9, but
// reportedly is not available in Ubuntu on Windows.
// See issue 16610.


Go patch committed: Fix double evaluation when using interface field expression

2018-07-09 Thread Ian Lance Taylor
This patch to the Go frontend by Cherry Zhang fixes the compiler to
avoid a double evaluation of an interface field expression.  In
Interface_field_reference_expression, the interface expression is used
in two places, so a temporary variable is used.  Previously, we used a
Set_and_use_temporary_expression, which, when evaluated twice, causes
double evaluation of the underlying expression.  Fix by setting the
temporary once and use Temporary_reference_expression instead.

This fixes https://golang.org/issue/26248.  The test case for this is
in https://golang.org/cl/122757.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262313)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-94738979a3422e845acf358a766aabf8b9275d43
+8ad67a72a4fa59efffc891e73ecf10020e3c565d
 
 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 262312)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -11886,10 +11886,9 @@ Interface_field_reference_expression::do
   if (!this->expr_->is_variable())
 {
   Temporary_statement* temp =
-   Statement::make_temporary(this->expr_->type(), NULL, this->location());
+   Statement::make_temporary(NULL, this->expr_, this->location());
   inserter->insert(temp);
-  this->expr_ = Expression::make_set_and_use_temporary(temp, this->expr_,
-  this->location());
+  this->expr_ = Expression::make_temporary_reference(temp, 
this->location());
 }
   return this;
 }


Go patch committed: Fix evaluation order of LHS index expressions

2018-07-11 Thread Ian Lance Taylor
The Go spec says that when an index expression appears on the left
hand side of an assignment, the operands should be evaluated. The
gofrontend code was assuming that that only referred to the index
operand. But discussion of https://golang.org/issue/23188 has
clarified that this means both the slice/map/string operand and the
index operand. This patch adjusts the gofrontend code accordingly,
fixing the issue.  The test case for this is in
https://golang.org/cl/123115.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262540)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-8ad67a72a4fa59efffc891e73ecf10020e3c565d
+ea7ac7784791dca517b6681a02c39c11bf136755
 
 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 262540)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -10898,6 +10898,20 @@ Array_index_expression::do_check_types(G
 }
 }
 
+// The subexpressions of an array index must be evaluated in order.
+// If this is indexing into an array, rather than a slice, then only
+// the index should be evaluated.  Since this is called for values on
+// the left hand side of an assigment, evaluating the array, meaning
+// copying the array, will cause a different array to be modified.
+
+bool
+Array_index_expression::do_must_eval_subexpressions_in_order(
+int* skip) const
+{
+  *skip = this->array_->type()->is_slice_type() ? 0 : 1;
+  return true;
+}
+
 // Flatten array indexing by using temporary variables for slices and indexes.
 
 Expression*
Index: gcc/go/gofrontend/expressions.h
===
--- gcc/go/gofrontend/expressions.h (revision 262540)
+++ gcc/go/gofrontend/expressions.h (working copy)
@@ -2771,12 +2771,10 @@ class Index_expression : public Parser_e
this->location());
   }
 
+  // This shouldn't be called--we don't know yet.
   bool
-  do_must_eval_subexpressions_in_order(int* skip) const
-  {
-*skip = 1;
-return true;
-  }
+  do_must_eval_subexpressions_in_order(int*) const
+  { go_unreachable(); }
 
   void
   do_dump_expression(Ast_dump_context*) const;
@@ -2882,11 +2880,7 @@ class Array_index_expression : public Ex
   }
 
   bool
-  do_must_eval_subexpressions_in_order(int* skip) const
-  {
-*skip = 1;
-return true;
-  }
+  do_must_eval_subexpressions_in_order(int* skip) const;
 
   bool
   do_is_addressable() const;
@@ -2965,11 +2959,8 @@ class String_index_expression : public E
   }
 
   bool
-  do_must_eval_subexpressions_in_order(int* skip) const
-  {
-*skip = 1;
-return true;
-  }
+  do_must_eval_subexpressions_in_order(int*) const
+  { return true; }
 
   Bexpression*
   do_get_backend(Translate_context*);
@@ -3052,11 +3043,8 @@ class Map_index_expression : public Expr
   }
 
   bool
-  do_must_eval_subexpressions_in_order(int* skip) const
-  {
-*skip = 1;
-return true;
-  }
+  do_must_eval_subexpressions_in_order(int*) const
+  { return true; }
 
   // A map index expression is an lvalue but it is not addressable.
 


Go patch committed: Build a single backend type for a type alias

2018-07-11 Thread Ian Lance Taylor
A type alias and its underlying type are identical.  This patch to the
Go frontend by Cherry Zhang builds a single backend type for them.
Previously we build two backend types, which sometimes confuse the
backend's type system.

Also don't include type aliases into the list of named type
declarations, since they are not named types.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262554)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-ea7ac7784791dca517b6681a02c39c11bf136755
+267686fd1dffbc03e610e9f17dadb4e72c75f18d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 262540)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -7604,7 +7604,7 @@ Named_object::get_backend(Gogo* gogo, st
 case NAMED_OBJECT_TYPE:
   {
 Named_type* named_type = this->u_.type_value;
-   if (!Gogo::is_erroneous_name(this->name_))
+   if (!Gogo::is_erroneous_name(this->name_) && !named_type->is_alias())
  type_decls.push_back(named_type->get_backend(gogo));
 
 // We need to produce a type descriptor for every named
Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc  (revision 262540)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -991,6 +991,11 @@ Type::get_backend(Gogo* gogo)
   if (this->btype_ != NULL)
 return this->btype_;
 
+  if (this->named_type() != NULL && this->named_type()->is_alias()) {
+this->btype_ = this->unalias()->get_backend(gogo);
+return this->btype_;
+  }
+
   if (this->forward_declaration_type() != NULL
   || this->named_type() != NULL)
 return this->get_btype_without_hash(gogo);


Go patch commited: Fix parsing of composite literals with omitted pointer types

2018-07-13 Thread Ian Lance Taylor
This patch to the Go frontend fixes parsing of composite literals with
omitted pointer types.  The frontend could parse omitted pointer
typess at the end of the type, but not in the middle, so code like
[]*[][]int{{{1}}} failed.  A test case is in
https://golang.org/cl/123477.  This fixes
https://golang.org/issue/26340.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262572)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-267686fd1dffbc03e610e9f17dadb4e72c75f18d
+3f7e72eca3f9221e67c055841d42851aa6a66aff
 
 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 262554)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -13666,6 +13666,7 @@ Composite_literal_expression::do_lower(G
 
   for (int depth = 0; depth < this->depth_; ++depth)
 {
+  type = type->deref();
   if (type->array_type() != NULL)
type = type->array_type()->element_type();
   else if (type->map_type() != NULL)


libgo patch committed: Skip zero-sized fields in structs when converting to libffi CIF

2018-07-13 Thread Ian Lance Taylor
The libffi library doesn't understand zero-sized objects.  This patch
to libgo fixes it so that when we see a zero-sized field in a struct,
we just skip it when converting to the libffi data structures. There
is no value to pass in any case, so not telling libffi about the field
doesn't affect anything.  The test case for this is
https://golang.org/cl/123316.  This fixes
https://golang.org/issue/26335.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262641)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-3f7e72eca3f9221e67c055841d42851aa6a66aff
+db991403fc97854201b3f40492f4f6b9d471cabc
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/ffi.go
===
--- libgo/go/runtime/ffi.go (revision 262540)
+++ libgo/go/runtime/ffi.go (working copy)
@@ -225,11 +225,40 @@ func structToFFI(typ *structtype) *__ffi
return emptyStructToFFI()
}
 
-   fields := make([]*__ffi_type, c+1)
+   fields := make([]*__ffi_type, 0, c+1)
+   checkPad := false
for i, v := range typ.fields {
-   fields[i] = typeToFFI(v.typ)
+   // Skip zero-sized fields; they confuse libffi,
+   // and there is no value to pass in any case.
+   // We do have to check whether the alignment of the
+   // zero-sized field introduces any padding for the
+   // next field.
+   if v.typ.size == 0 {
+   checkPad = true
+   continue
+   }
+
+   if checkPad {
+   off := uintptr(0)
+   for j := i - 1; j >= 0; j-- {
+   if typ.fields[j].typ.size > 0 {
+   off = typ.fields[j].offset() + 
typ.fields[j].typ.size
+   break
+   }
+   }
+   off += uintptr(v.typ.align) - 1
+   off &^= uintptr(v.typ.align) - 1
+   if off != v.offset() {
+   fields = append(fields, padFFI(v.offset()-off))
+   }
+   checkPad = false
+   }
+
+   fields = append(fields, typeToFFI(v.typ))
}
-   fields[c] = nil
+
+   fields = append(fields, nil)
+
return &__ffi_type{
_type:_FFI_TYPE_STRUCT,
elements: &fields[0],
@@ -302,6 +331,19 @@ func emptyStructToFFI() *__ffi_type {
return &__ffi_type{
_type:_FFI_TYPE_STRUCT,
elements: &elements[0],
+   }
+}
+
+// padFFI returns a padding field of the given size
+func padFFI(size uintptr) *__ffi_type {
+   elements := make([]*__ffi_type, size+1)
+   for i := uintptr(0); i < size; i++ {
+   elements[i] = ffi_type_uint8()
+   }
+   elements[size] = nil
+   return &__ffi_type{
+   _type:_FFI_TYPE_STRUCT,
+   elements: &elements[0],
}
 }
 


Go patch committed: Connect the concrete type and the placeholder for circular types

2018-07-17 Thread Ian Lance Taylor
This patch by Cherry Zhang changes the Go frontend to more clearly
connect the concrete type and the placeholder for circular types.
Previously, when creating the backend representation of a circular
type, we resolved the placeholder to a circular_pointer_type.  The
backend didn't know what the concrete type would be.  This patch
changes the frontend to resolve the placeholder to the concrete type
instead, so the backend can have better knowledge of the concrete
type.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262658)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-db991403fc97854201b3f40492f4f6b9d471cabc
+d6338c94e5574b63469c740159d064e89c6718bf
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc  (revision 262658)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -10786,15 +10786,10 @@ Named_type::do_get_backend(Gogo* gogo)
   // Don't build a circular data structure.  GENERIC can't handle
   // it.
   if (this->seen_in_get_backend_)
-   {
- this->is_circular_ = true;
- return gogo->backend()->circular_pointer_type(bt, true);
-   }
+return gogo->backend()->circular_pointer_type(bt, true);
   this->seen_in_get_backend_ = true;
   bt1 = Type::get_named_base_btype(gogo, base);
   this->seen_in_get_backend_ = false;
-  if (this->is_circular_)
-   bt1 = gogo->backend()->circular_pointer_type(bt, true);
   if (!gogo->backend()->set_placeholder_pointer_type(bt, bt1))
bt = gogo->backend()->error_type();
   return bt;
@@ -10803,15 +10798,10 @@ Named_type::do_get_backend(Gogo* gogo)
   // Don't build a circular data structure. GENERIC can't handle
   // it.
   if (this->seen_in_get_backend_)
-   {
- this->is_circular_ = true;
- return gogo->backend()->circular_pointer_type(bt, false);
-   }
+return gogo->backend()->circular_pointer_type(bt, false);
   this->seen_in_get_backend_ = true;
   bt1 = Type::get_named_base_btype(gogo, base);
   this->seen_in_get_backend_ = false;
-  if (this->is_circular_)
-   bt1 = gogo->backend()->circular_pointer_type(bt, false);
   if (!gogo->backend()->set_placeholder_pointer_type(bt, bt1))
bt = gogo->backend()->error_type();
   return bt;
Index: gcc/go/gofrontend/types.h
===
--- gcc/go/gofrontend/types.h   (revision 262658)
+++ gcc/go/gofrontend/types.h   (working copy)
@@ -3243,8 +3243,8 @@ class Named_type : public Type
   interface_method_tables_(NULL), pointer_interface_method_tables_(NULL),
   location_(location), named_btype_(NULL), dependencies_(),
   is_alias_(false), is_visible_(true), is_error_(false), in_heap_(true),
-  is_placeholder_(false), is_converted_(false), is_circular_(false),
-  is_verified_(false), seen_(false), seen_in_compare_is_identity_(false),
+  is_placeholder_(false), is_converted_(false), is_verified_(false),
+  seen_(false), seen_in_compare_is_identity_(false),
   seen_in_get_backend_(false), seen_alias_(false)
   { }
 
@@ -3345,12 +3345,6 @@ class Named_type : public Type
   is_valid() const
   { return !this->is_error_; }
 
-  // Whether this is a circular type: a pointer or function type that
-  // refers to itself, which is not possible in C.
-  bool
-  is_circular() const
-  { return this->is_circular_; }
-
   // Return the base type for this type.
   Type*
   named_base();
@@ -3557,9 +3551,6 @@ class Named_type : public Type
   // Whether this type has been converted to the backend
   // representation.  Implies that is_placeholder_ is false.
   bool is_converted_;
-  // Whether this is a pointer or function type which refers to the
-  // type itself.
-  bool is_circular_;
   // Whether this type has been verified.
   bool is_verified_;
   // In a recursive operation such as has_pointer, this flag is used


Go patch committed: Don't set btype_ field too early for an alias type

2018-07-17 Thread Ian Lance Taylor
This patch by Cherry Zhang fixes a problem in the Go frontend
introduced by https://golang.org/cl/123362.  A type's btype_ field
should not be set before named types are converted if it is a
placeholder.  For alias type, it iwas set too early.  That could
result in unresolved placeholders.  This patch fixes the problem.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262830)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-d6338c94e5574b63469c740159d064e89c6718bf
+38850073f25f9de4f3daa33d799def3a33c942ab
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc  (revision 262830)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -992,8 +992,10 @@ Type::get_backend(Gogo* gogo)
 return this->btype_;
 
   if (this->named_type() != NULL && this->named_type()->is_alias()) {
-this->btype_ = this->unalias()->get_backend(gogo);
-return this->btype_;
+Btype* bt = this->unalias()->get_backend(gogo);
+if (gogo != NULL && gogo->named_types_are_converted())
+  this->btype_ = bt;
+return bt;
   }
 
   if (this->forward_declaration_type() != NULL


Go patch committed: Fix order of evaluation of boolean expressions

2018-07-20 Thread Ian Lance Taylor
This patch by Cherry Zhang changes the Go frontend to run the
order_evaluations before the remove_shortcuts pass.

In remove_shortcuts, the shortcut expressions (&&, ||) are rewritten
to if statements, which are lifted out before the statement containing
the shortcut expression.  If the containing statement has other
(sub)expressions that should be evaluated before the shortcut
expression, which has not been lifted out, this will result in
incorrect evaluation order.

For example, F() + G(A() && B()), the evaluation order per the
language spec is F, A, B (if A returns true), G. If we lift A() and
B() out first, they will be called before F, which is wrong.

To fix this, this patch splits order_evaluations to two phases.  The
first phase, which runs before remove_shortcuts, skips shortcut
expressions' components.  So it won't lift out subexpressions that are
evaluated conditionally.  The shortcut expression itself is ordered,
since it may have side effects.  Then we run remove_shortcuts.  At
this point the subexpressions that should be evaluated before the
shortcut expression are already lifted out.  The remove_shortcuts pass
also runs the second phase of order_evaluations to order the
components of shortcut expressions, which were skipped during the
first phase.

This reorders the code blocks of remove_shortcuts and
order_evaluations, since remove_shortcuts now calls Order_eval.

This fixes https://golang.org/issue/26495.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262833)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-38850073f25f9de4f3daa33d799def3a33c942ab
+39d4d755db7d71b5e770ca435a8b1d1f08f53185
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/go.cc
===
--- gcc/go/gofrontend/go.cc (revision 262658)
+++ gcc/go/gofrontend/go.cc (working copy)
@@ -143,12 +143,12 @@ go_parse_input_files(const char** filena
   // Export global identifiers as appropriate.
   ::gogo->do_exports();
 
-  // Turn short-cut operators (&&, ||) into explicit if statements.
-  ::gogo->remove_shortcuts();
-
   // Use temporary variables to force order of evaluation.
   ::gogo->order_evaluations();
 
+  // Turn short-cut operators (&&, ||) into explicit if statements.
+  ::gogo->remove_shortcuts();
+
   // Convert named types to backend representation.
   ::gogo->convert_named_types();
 
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 262658)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -3432,210 +3432,6 @@ Gogo::check_types_in_block(Block* block)
   block->traverse(&traverse);
 }
 
-// A traversal class used to find a single shortcut operator within an
-// expression.
-
-class Find_shortcut : public Traverse
-{
- public:
-  Find_shortcut()
-: Traverse(traverse_blocks
-  | traverse_statements
-  | traverse_expressions),
-  found_(NULL)
-  { }
-
-  // A pointer to the expression which was found, or NULL if none was
-  // found.
-  Expression**
-  found() const
-  { return this->found_; }
-
- protected:
-  int
-  block(Block*)
-  { return TRAVERSE_SKIP_COMPONENTS; }
-
-  int
-  statement(Block*, size_t*, Statement*)
-  { return TRAVERSE_SKIP_COMPONENTS; }
-
-  int
-  expression(Expression**);
-
- private:
-  Expression** found_;
-};
-
-// Find a shortcut expression.
-
-int
-Find_shortcut::expression(Expression** pexpr)
-{
-  Expression* expr = *pexpr;
-  Binary_expression* be = expr->binary_expression();
-  if (be == NULL)
-return TRAVERSE_CONTINUE;
-  Operator op = be->op();
-  if (op != OPERATOR_OROR && op != OPERATOR_ANDAND)
-return TRAVERSE_CONTINUE;
-  go_assert(this->found_ == NULL);
-  this->found_ = pexpr;
-  return TRAVERSE_EXIT;
-}
-
-// A traversal class used to turn shortcut operators into explicit if
-// statements.
-
-class Shortcuts : public Traverse
-{
- public:
-  Shortcuts(Gogo* gogo)
-: Traverse(traverse_variables
-  | traverse_statements),
-  gogo_(gogo)
-  { }
-
- protected:
-  int
-  variable(Named_object*);
-
-  int
-  statement(Block*, size_t*, Statement*);
-
- private:
-  // Convert a shortcut operator.
-  Statement*
-  convert_shortcut(Block* enclosing, Expression** pshortcut);
-
-  // The IR.
-  Gogo* gogo_;
-};
-
-// Remove shortcut operators in a single statement.
-
-int
-Shortcuts::statement(Block* block, size_t* pindex, Statement* s)
-{
-  // FIXME: This approach doesn't work for switch statements, because
-  // we add the new statements before the whole switch when we need to
-  // instead add them just before the switch expression.  The right
-  // fix is probably to lower switch statem

libgo patch committed: Prune sighandler frames in runtime.sigprof

2018-07-27 Thread Ian Lance Taylor
This libgo patch by Than McIntosh prunes sighandler frames in
runtime.sigprof.  When writing stack frames to the pprof CPU profile
machinery, it is very important to insure that the frames emitted do
not contain any frames corresponding to artifacts of the profiling
process itself (signal handlers, sigprof, etc).  This patch changes
runtime.sigprof to strip out those frames from the raw stack generated
by "runtime.callers".  This fixes https://golang.org/issue/26595.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 262908)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-39d4d755db7d71b5e770ca435a8b1d1f08f53185
+a2e0ad16555b2698df8e71f4c0fe02e185715bc1
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/pprof/pprof_test.go
===
--- libgo/go/runtime/pprof/pprof_test.go(revision 262658)
+++ libgo/go/runtime/pprof/pprof_test.go(working copy)
@@ -72,15 +72,24 @@ func cpuHog2(x int) int {
return foo
 }
 
+// Return a list of functions that we don't want to ever appear in CPU
+// profiles. For gccgo, that list includes the sigprof handler itself.
+func avoidFunctions() []string {
+   if runtime.Compiler == "gccgo" {
+   return []string{"runtime.sigprof"}
+   }
+   return nil
+}
+
 func TestCPUProfile(t *testing.T) {
-   testCPUProfile(t, []string{"pprof.cpuHog1"}, func(dur time.Duration) {
+   testCPUProfile(t, []string{"pprof.cpuHog1"}, avoidFunctions(), func(dur 
time.Duration) {
cpuHogger(cpuHog1, &salt1, dur)
})
 }
 
 func TestCPUProfileMultithreaded(t *testing.T) {
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2))
-   testCPUProfile(t, []string{"pprof.cpuHog1", "pprof.cpuHog2"}, func(dur 
time.Duration) {
+   testCPUProfile(t, []string{"pprof.cpuHog1", "pprof.cpuHog2"}, 
avoidFunctions(), func(dur time.Duration) {
c := make(chan int)
go func() {
cpuHogger(cpuHog1, &salt1, dur)
@@ -92,7 +101,7 @@ func TestCPUProfileMultithreaded(t *test
 }
 
 func TestCPUProfileInlining(t *testing.T) {
-   testCPUProfile(t, []string{"pprof.inlinedCallee", 
"pprof.inlinedCaller"}, func(dur time.Duration) {
+   testCPUProfile(t, []string{"pprof.inlinedCallee", 
"pprof.inlinedCaller"}, avoidFunctions(), func(dur time.Duration) {
cpuHogger(inlinedCaller, &salt1, dur)
})
 }
@@ -130,7 +139,7 @@ func parseProfile(t *testing.T, valBytes
}
 }
 
-func testCPUProfile(t *testing.T, need []string, f func(dur time.Duration)) {
+func testCPUProfile(t *testing.T, need []string, avoid []string, f func(dur 
time.Duration)) {
switch runtime.GOOS {
case "darwin":
switch runtime.GOARCH {
@@ -169,7 +178,7 @@ func testCPUProfile(t *testing.T, need [
f(duration)
StopCPUProfile()
 
-   if profileOk(t, need, prof, duration) {
+   if profileOk(t, need, avoid, prof, duration) {
return
}
 
@@ -202,11 +211,13 @@ func contains(slice []string, s string)
return false
 }
 
-func profileOk(t *testing.T, need []string, prof bytes.Buffer, duration 
time.Duration) (ok bool) {
+func profileOk(t *testing.T, need []string, avoid []string, prof bytes.Buffer, 
duration time.Duration) (ok bool) {
ok = true
 
-   // Check that profile is well formed and contains need.
+   // Check that profile is well formed, contains 'need', and does not 
contain
+   // anything from 'avoid'.
have := make([]uintptr, len(need))
+   avoidSamples := make([]uintptr, len(avoid))
var samples uintptr
var buf bytes.Buffer
parseProfile(t, prof.Bytes(), func(count uintptr, stk 
[]*profile.Location, labels map[string][]string) {
@@ -229,6 +240,15 @@ func profileOk(t *testing.T, need []stri
}
}
}
+   for i, name := range avoid {
+   for _, loc := range stk {
+   for _, line := range loc.Line {
+   if strings.Contains(line.Function.Name, 
name) {
+   avoidSamples[i] += count
+   }
+   }
+   }
+   }
fmt.Fprintf(&buf, "\n")
})
t.Logf("total %d CPU profile samples collected:\n%s", samples, 
buf.String())
@@ -251,6 +271,14 @@ func profileOk(t *testing.T, need []stri
ok = false
}
 
+   for i, name := range avoid {
+

Re: [PATCH] Make GO string literals properly NUL terminated

2018-07-31 Thread Ian Lance Taylor
On Tue, Jul 31, 2018 at 5:14 AM, Bernd Edlinger
 wrote:
>
> could someone please review this patch and check it in into the GO FE?

I don't understand why the change is correct, and you didn't explain
it.  Go strings are not NUL terminated.  Go strings always have an
associated length.

Ian


Re: [PATCH] Make GO string literals properly NUL terminated

2018-07-31 Thread Ian Lance Taylor
On Tue, Jul 31, 2018 at 9:19 AM, Bernd Edlinger
 wrote:
> On 07/31/18 16:40, Ian Lance Taylor wrote:
>> On Tue, Jul 31, 2018 at 5:14 AM, Bernd Edlinger
>>  wrote:
>>>
>>> could someone please review this patch and check it in into the GO FE?
>>
>> I don't understand why the change is correct, and you didn't explain
>> it.  Go strings are not NUL terminated.  Go strings always have an
>> associated length.
>>
>
> Yes, sorry.  Effectively for go this change is a no-op.
> I'll elaborate a bit.
>
> This makes it easier for the middle-end to distinguish between nul-terminated
> and not nul terminated strings.  Especially if wide character strings
> may also may come along.
>
> In C a not nul terminated string might be declared like
> char x[2] = "12";
> it is always a STRING_CST object of length 3, with value "12\0".
> The array_type is char[0..1]
>
> while a nul terminated string is declared like
> char x[3] = "12"
> it is also a STRING_CST object of length 3, with value "12\0"
> The array_type is char[0..2]
>
> Note however the array type is different.
> So with this convention one only needs to compare the array type
> size with the string length which is much easier than looking for
> a terminating wide character, which is rarely done right.
>
> At the end varasm.c filters the excess NUL byte away, but
> I would like to add a checking assertion there that this does not
> strip more than max. one wide character nul byte.

Thanks, I think I should probably let this be reviewed by someone
reviewing the larger patch.  The go-gcc.cc file lives in the GCC repo
and changes to it can be approved and committed by any GCC middle-end
or global maintainer.  It's not part of the code copied from another
repo, which lives in gcc/go/gofrontend.

Ian


Merge from trunk to gccgo branch

2018-07-31 Thread Ian Lance Taylor
I've merged trunk revision 263114 to the gccgo branch.

Ian


libgo patch committed: Use poll rather than pollset on AIX

2018-07-31 Thread Ian Lance Taylor
This patch by Tony Reix changes libgo's poller support on AIX to use
poll rather than pollset.  This may fixes
https://golang.org/issue/26634.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux, not that that proves much.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 263179)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-a2e0ad16555b2698df8e71f4c0fe02e185715bc1
+8997a3afcc746824cb70b48b32d9c86b4814807d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/netpoll.go
===
--- libgo/go/runtime/netpoll.go (revision 263179)
+++ libgo/go/runtime/netpoll.go (working copy)
@@ -169,8 +169,8 @@ func poll_runtime_pollWait(pd *pollDesc,
if err != 0 {
return err
}
-   // As for now only Solaris uses level-triggered IO.
-   if GOOS == "solaris" {
+   // As for now only Solaris and AIX use level-triggered IO.
+   if GOOS == "solaris" || GOOS == "aix" {
netpollarm(pd, mode)
}
for !netpollblock(pd, int32(mode), false) {
Index: libgo/go/runtime/netpoll_aix.go
===
--- libgo/go/runtime/netpoll_aix.go (revision 263179)
+++ libgo/go/runtime/netpoll_aix.go (working copy)
@@ -7,9 +7,7 @@ package runtime
 import "unsafe"
 
 // This is based on the former libgo/runtime/netpoll_select.c implementation
-// except that it uses AIX pollset_poll instead of select and is written in Go.
-
-type pollset_t int32
+// except that it uses poll instead of select and is written in Go.
 
 type pollfd struct {
fd  int32
@@ -22,25 +20,9 @@ const _POLLOUT = 0x0002
 const _POLLHUP = 0x2000
 const _POLLERR = 0x4000
 
-type poll_ctl struct {
-   cmdint16
-   events int16
-   fd int32
-}
-
-const _PS_ADD = 0x0
-const _PS_DELETE = 0x2
-
-//extern pollset_create
-func pollset_create(maxfd int32) pollset_t
-
 //go:noescape
-//extern pollset_ctl
-func pollset_ctl(ps pollset_t, pollctl_array *poll_ctl, array_length int32) 
int32
-
-//go:noescape
-//extern pollset_poll
-func pollset_poll(ps pollset_t, polldata_array *pollfd, array_length int32, 
timeout int32) int32
+//extern poll
+func libc_poll(pfds *pollfd, npfds uintptr, timeout uintptr) int32
 
 //go:noescape
 //extern pipe
@@ -55,9 +37,10 @@ func fcntl(fd, cmd int32, arg uintptr) u
 }
 
 var (
-   ps  pollset_t = -1
-   mpfds   map[int32]*pollDesc
-   pmtxmutex
+   pfds[]pollfd
+   pds []*pollDesc
+   mtxpoll mutex
+   mtxset  mutex
rdwake  int32
wrwake  int32
needsUpdate bool
@@ -66,13 +49,7 @@ var (
 func netpollinit() {
var p [2]int32
 
-   if ps = pollset_create(-1); ps < 0 {
-   throw("runtime: netpollinit failed to create pollset")
-   }
-   // It is not possible to add or remove descriptors from
-   // the pollset while pollset_poll is active.
-   // We use a pipe to wakeup pollset_poll when the pollset
-   // needs to be updated.
+   // Create the pipe we use to wakeup poll.
if err := libc_pipe(&p[0]); err < 0 {
throw("runtime: netpollinit failed to create pipe")
}
@@ -84,127 +61,136 @@ func netpollinit() {
fcntl(rdwake, _F_SETFD, _FD_CLOEXEC)
 
fl = fcntl(wrwake, _F_GETFL, 0)
-   fcntl(wrwake, _F_SETFL, fl|_O_NONBLOCK)
fcntl(wrwake, _F_SETFD, _FD_CLOEXEC)
 
-   // Add the read side of the pipe to the pollset.
-   var pctl poll_ctl
-   pctl.cmd = _PS_ADD
-   pctl.fd = rdwake
-   pctl.events = _POLLIN
-   if pollset_ctl(ps, &pctl, 1) != 0 {
-   throw("runtime: netpollinit failed to register pipe")
-   }
-
-   mpfds = make(map[int32]*pollDesc)
+   // Pre-allocate array of pollfd structures for poll.
+   pfds = make([]pollfd, 1, 128)
+   // Poll the read side of the pipe.
+   pfds[0].fd = rdwake
+   pfds[0].events = _POLLIN
+
+   // Allocate index to pd array
+   pds = make([]*pollDesc, 1, 128)
+   pds[0] = nil
 }
 
 func netpolldescriptor() uintptr {
-   // ps is not a real file descriptor.
return ^uintptr(0)
 }
 
-func netpollopen(fd uintptr, pd *pollDesc) int32 {
-   // pollset_ctl will block if pollset_poll is active
-   // so wakeup pollset_poll first.
-   lock(&pmtx)
-   needsUpdate = true
-   unlock(&pmtx)
-   b := [1]byte{0}
-   write(uintptr(wrwake), unsafe.Pointer(&b[0]), 1)
-
-   var pctl poll_ctl
-   pctl.cmd = _PS_ADD
-   pctl.fd = int32(fd)
-   pctl.events = _POLLIN | _POLLOUT
-   if pollset_ctl(ps, &pctl, 1) != 0 {
-   return int32(errno())
+func netpollwakeup(

Go patch committed: pass Gogo to more passes

2023-10-22 Thread Ian Lance Taylor
This patch to the G frontend passes a pointer to the Gogo IR to the
determine types pass and the type verification pass.  This is a
straight refactoring that does not change the compiler behavior.  This
is in preparation for future CLs that rearrange the pass ordering.

This introduces one new call to go_get_gogo, which will be removed in
a future CL.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
b513aa235d6e5d7e2a36ee789c60891fce873340
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index d24054e0d93..28683d6852b 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-967a215d6419c3db58f8f59a0c252c458abce395
+06ada1f2ab9b05e54641438db28c557c6900b2a3
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index d276bd811cc..273831fabf3 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -205,18 +205,18 @@ Expression::report_error(const char* msg)
 // child class.
 
 void
-Expression::determine_type(const Type_context* context)
+Expression::determine_type(Gogo* gogo, const Type_context* context)
 {
-  this->do_determine_type(context);
+  this->do_determine_type(gogo, context);
 }
 
 // Set types when there is no context.
 
 void
-Expression::determine_type_no_context()
+Expression::determine_type_no_context(Gogo* gogo)
 {
   Type_context context;
-  this->do_determine_type(&context);
+  this->do_determine_type(gogo, &context);
 }
 
 // Return true if two expressions refer to the same variable or struct
@@ -842,7 +842,7 @@ class Error_expression : public Expression
   { return Type::make_error_type(); }
 
   void
-  do_determine_type(const Type_context*)
+  do_determine_type(Gogo*, const Type_context*)
   { }
 
   Expression*
@@ -897,7 +897,7 @@ Type_expression : public Expression
   { return this->type_; }
 
   void
-  do_determine_type(const Type_context*)
+  do_determine_type(Gogo*, const Type_context*)
   { }
 
   void
@@ -998,10 +998,10 @@ Var_expression::do_type()
 // Determine the type of a reference to a variable.
 
 void
-Var_expression::do_determine_type(const Type_context*)
+Var_expression::do_determine_type(Gogo* gogo, const Type_context*)
 {
   if (this->variable_->is_variable())
-this->variable_->var_value()->determine_type();
+this->variable_->var_value()->determine_type(gogo);
 }
 
 // Something takes the address of this variable.  This means that we
@@ -1303,9 +1303,10 @@ Set_and_use_temporary_expression::do_type()
 
 void
 Set_and_use_temporary_expression::do_determine_type(
+Gogo* gogo,
 const Type_context* context)
 {
-  this->expr_->determine_type(context);
+  this->expr_->determine_type(gogo, context);
 }
 
 // Take the address.
@@ -1378,7 +1379,7 @@ class Sink_expression : public Expression
   do_type();
 
   void
-  do_determine_type(const Type_context*);
+  do_determine_type(Gogo*, const Type_context*);
 
   Expression*
   do_copy()
@@ -1410,7 +1411,7 @@ Sink_expression::do_type()
 // Determine the type of a sink expression.
 
 void
-Sink_expression::do_determine_type(const Type_context* context)
+Sink_expression::do_determine_type(Gogo*, const Type_context* context)
 {
   if (context->type != NULL)
 this->type_ = context->type;
@@ -1805,7 +1806,7 @@ class Func_code_reference_expression : public Expression
   { return Type::make_pointer_type(Type::make_void_type()); }
 
   void
-  do_determine_type(const Type_context*)
+  do_determine_type(Gogo*, const Type_context*)
   { }
 
   Expression*
@@ -1983,7 +1984,7 @@ class Boolean_expression : public Expression
   do_type();
 
   void
-  do_determine_type(const Type_context*);
+  do_determine_type(Gogo*, const Type_context*);
 
   Expression*
   do_copy()
@@ -2035,7 +2036,7 @@ Boolean_expression::do_type()
 // Set the type from the context.
 
 void
-Boolean_expression::do_determine_type(const Type_context* context)
+Boolean_expression::do_determine_type(Gogo*, const Type_context* context)
 {
   if (this->type_ != NULL && !this->type_->is_abstract())
 ;
@@ -2108,7 +2109,7 @@ String_expression::do_type()
 // Set the type from the context.
 
 void
-String_expression::do_determine_type(const Type_context* context)
+String_expression::do_determine_type(Gogo*, const Type_context* context)
 {
   if (this->type_ != NULL && !this->type_->is_abstract())
 ;
@@ -2278,7 +2279,7 @@ class String_info_expression : public Expression
   do_type();
 
   void
-  do_determine_type(const Type_context*)
+  do_determine_type(Gogo*, const Type_context*)
   { go_unreachable(); }
 
   Expression*
@@ -2390,7 +2391,7 @@ class String_value_expression : public Expression
   { return Type::make_string_type(); }
 
   void
-  do_determine_type(const Type_context*)
+  do_determine_type(Gogo*, const Type_context*)
   { go_unreachable(); }
 
   Expression*
@@ -2499,7 +2500,7 @@ class Integ

Go patch committed: Remove name_ field from Type_switch_statement

2023-10-22 Thread Ian Lance Taylor
This patch to the Go frontend removes the name_ field from the
Type_switch_statement class.  It's not used for anything.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
1a1fba1e25779247a4969789885ce80b7b4a2359
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 28683d6852b..d31fb336e41 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-06ada1f2ab9b05e54641438db28c557c6900b2a3
+75b08794cb1485c955d13784c53a89174764af55
 
 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/parse.cc b/gcc/go/gofrontend/parse.cc
index c93d82bba39..d7410588347 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -4932,7 +4932,7 @@ Parse::type_switch_body(Label* label, const Type_switch& 
type_switch,
 }
 
   Type_switch_statement* statement =
-  Statement::make_type_switch_statement(var_name, init, location);
+  Statement::make_type_switch_statement(init, location);
   this->push_break_statement(statement, label);
 
   Type_case_clauses* case_clauses = new Type_case_clauses();
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 33b568e3eeb..b43f1393e33 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -5046,8 +5046,6 @@ 
Type_switch_statement::do_dump_statement(Ast_dump_context* ast_dump_context)
 {
   ast_dump_context->print_indent();
   ast_dump_context->ostream() << "switch ";
-  if (!this->name_.empty())
-ast_dump_context->ostream() << this->name_ << " = ";
   ast_dump_context->dump_expression(this->expr_);
   ast_dump_context->ostream() << " .(type)";
   if (ast_dump_context->dump_subblocks())
@@ -5062,10 +5060,9 @@ 
Type_switch_statement::do_dump_statement(Ast_dump_context* ast_dump_context)
 // Make a type switch statement.
 
 Type_switch_statement*
-Statement::make_type_switch_statement(const std::string& name, Expression* 
expr,
- Location location)
+Statement::make_type_switch_statement(Expression* expr, Location location)
 {
-  return new Type_switch_statement(name, expr, location);
+  return new Type_switch_statement(expr, location);
 }
 
 // Class Send_statement.
diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h
index eb795c4b920..9ef63cb9a61 100644
--- a/gcc/go/gofrontend/statements.h
+++ b/gcc/go/gofrontend/statements.h
@@ -253,7 +253,7 @@ class Statement
 
   // Make a type switch statement.
   static Type_switch_statement*
-  make_type_switch_statement(const std::string&, Expression*, Location);
+  make_type_switch_statement(Expression*, Location);
 
   // Make a send statement.
   static Send_statement*
@@ -2191,10 +2191,9 @@ class Type_case_clauses
 class Type_switch_statement : public Statement
 {
  public:
-  Type_switch_statement(const std::string& name, Expression* expr,
-   Location location)
+  Type_switch_statement(Expression* expr, Location location)
 : Statement(STATEMENT_TYPE_SWITCH, location),
-  name_(name), expr_(expr), clauses_(NULL), break_label_(NULL)
+  expr_(expr), clauses_(NULL), break_label_(NULL)
   { }
 
   // Add the clauses.
@@ -2227,10 +2226,7 @@ class Type_switch_statement : public Statement
   do_may_fall_through() const;
 
  private:
-  // The name of the variable declared in the type switch guard.  Empty if 
there
-  // is no variable declared.
-  std::string name_;
-  // The expression we are switching on if there is no variable.
+  // The expression we are switching on.
   Expression* expr_;
   // The type case clauses.
   Type_case_clauses* clauses_;


Go patch committed: Remove the traverse_assignments code

2023-10-22 Thread Ian Lance Taylor
This patch to the Go frontend removes the traverse_assignments
support.  The last caller was removed in https://go.dev/cl/18261 in
2016.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
a6e74b0b3316f3f0b2096d6a175c31bed58ae4ed
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index d31fb336e41..398d2671b64 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-75b08794cb1485c955d13784c53a89174764af55
+c201fa2a684ada551ca9a0825a3075a0a69498de
 
 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/statements.cc b/gcc/go/gofrontend/statements.cc
index b43f1393e33..91c7627a0e3 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -64,16 +64,6 @@ Statement::traverse_contents(Traverse* traverse)
   return this->do_traverse(traverse);
 }
 
-// Traverse assignments.
-
-bool
-Statement::traverse_assignments(Traverse_assignments* tassign)
-{
-  if (this->classification_ == STATEMENT_ERROR)
-return false;
-  return this->do_traverse_assignments(tassign);
-}
-
 // Traverse an expression in a statement.  This is a helper function
 // for child classes.
 
@@ -288,17 +278,6 @@ Variable_declaration_statement::do_traverse(Traverse*)
   return TRAVERSE_CONTINUE;
 }
 
-// Traverse the assignments in a variable declaration.  Note that this
-// traversal is different from the usual traversal.
-
-bool
-Variable_declaration_statement::do_traverse_assignments(
-Traverse_assignments* tassign)
-{
-  tassign->initialize_variable(this->var_);
-  return true;
-}
-
 // Lower the variable's initialization expression.
 
 Statement*
@@ -510,17 +489,6 @@ Temporary_statement::do_traverse(Traverse* traverse)
 return this->traverse_expression(traverse, &this->init_);
 }
 
-// Traverse assignments.
-
-bool
-Temporary_statement::do_traverse_assignments(Traverse_assignments* tassign)
-{
-  if (this->init_ == NULL)
-return false;
-  tassign->value(&this->init_, true, true);
-  return true;
-}
-
 // Determine types.
 
 void
@@ -889,13 +857,6 @@ Assignment_statement::do_traverse(Traverse* traverse)
   return this->traverse_expression(traverse, &this->rhs_);
 }
 
-bool
-Assignment_statement::do_traverse_assignments(Traverse_assignments* tassign)
-{
-  tassign->assignment(&this->lhs_, &this->rhs_);
-  return true;
-}
-
 // Lower an assignment to a map index expression to a runtime function
 // call.  Mark some slice assignments as not requiring a write barrier.
 
@@ -1212,10 +1173,6 @@ class Assignment_operation_statement : public Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1365,10 +1322,6 @@ class Tuple_assignment_statement : public Statement
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1511,10 +1464,6 @@ public:
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1719,10 +1668,6 @@ class Tuple_receive_assignment_statement : public 
Statement
   int
   do_traverse(Traverse* traverse);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -1862,10 +1807,6 @@ class Tuple_type_guard_assignment_statement : public 
Statement
   int
   do_traverse(Traverse*);
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -2277,10 +2218,6 @@ class Inc_dec_statement : public Statement
   do_traverse(Traverse* traverse)
   { return this->traverse_expression(traverse, &this->expr_); }
 
-  bool
-  do_traverse_assignments(Traverse_assignments*)
-  { go_unreachable(); }
-
   Statement*
   do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
 
@@ -2412,18 +2349,6 @@ Thunk_statement::do_traverse(Traverse* traverse)
   return this->traverse_expression(traverse, &this->call_);
 }
 
-// We implement traverse_assignment for a thunk statement because it
-// effectively copies the function call.
-
-bool
-Thunk_statement::do_traverse_assignments(Traverse_assignments* tassign)
-{
-  Expression* fn = this->call_->call_expression()->fn();
-  Expression* fn2 = fn;
-  tassign->value(&fn2, true, false);
-  return true;
-}
-
 // Determine types in a thunk statement.
 
 void
@@ -3148,23 +3073,6 @@ Statement::make_defer_statement(Call_expression* call,
 
 // Class Return_statement.
 
-// Traverse assignments.  We treat each return value as a t

libgo patch committed: Add missing type conversion

2023-10-23 Thread Ian Lance Taylor
This libgo patch adds a missing type conversion.  The gofrontend
incorrectly accepted code that was missing a type conversion.  The
test case for this is bug518.go in https://go.dev/cl/536537.  Future
CLs in this series will detect the type error.  Bootstrapped and ran
Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
2621bd1bac614b63e52d0deb4ab2ff287a9fafa8
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 398d2671b64..0f961157dfd 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-c201fa2a684ada551ca9a0825a3075a0a69498de
+081ec9824a74ec9d82628d8d2f6b9a7a4c35a529
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go
index 9f688e2a0c7..02f228adc59 100644
--- a/libgo/go/syscall/errstr.go
+++ b/libgo/go/syscall/errstr.go
@@ -24,7 +24,7 @@ func Errstr(errnum int) string {
}
return string(b[:i])
}
-   if errno != ERANGE {
+   if Errno(errno) != ERANGE {
return "strerror_r failure"
}
}


Go patch committed: Add Expression::is_untyped method

2023-10-23 Thread Ian Lance Taylor
This Go frontend patches adds an Expression::is_untyped method.  This
method is not currently used by anything, but it will be used by later
changes in this series.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
ac50e9b72bf9bb6d5b28096bb164fb050db6e290
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 0f961157dfd..d4095637cea 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-081ec9824a74ec9d82628d8d2f6b9a7a4c35a529
+1c0a7c9338801d15afba7e39109554ed3406654e
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 273831fabf3..5bea6238def 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -201,6 +201,19 @@ Expression::report_error(const char* msg)
   this->set_is_error();
 }
 
+// A convenience function for handling a type in do_is_untyped.  If
+// TYPE is not abstract, return false.  Otherwise set *PTYPE to TYPE
+// and return true.
+
+bool
+Expression::is_untyped_type(Type* type, Type** ptype)
+{
+  if (!type->is_abstract())
+return false;
+  *ptype = type;
+  return true;
+}
+
 // Set types of variables and constants.  This is implemented by the
 // child class.
 
@@ -826,6 +839,10 @@ class Error_expression : public Expression
   do_is_constant() const
   { return true; }
 
+  bool
+  do_is_untyped(Type**) const
+  { return false; }
+
   bool
   do_numeric_constant_value(Numeric_constant* nc) const
   {
@@ -1965,6 +1982,9 @@ class Boolean_expression : public Expression
   do_is_constant() const
   { return true; }
 
+  bool
+  do_is_untyped(Type**) const;
+
   bool
   do_is_zero_value() const
   { return this->val_ == false; }
@@ -2023,6 +2043,15 @@ Boolean_expression::do_traverse(Traverse* traverse)
   return TRAVERSE_CONTINUE;
 }
 
+bool
+Boolean_expression::do_is_untyped(Type** ptype) const
+{
+  if (this->type_ != NULL)
+return Expression::is_untyped_type(this->type_, ptype);
+  *ptype = Type::make_boolean_type();
+  return true;
+}
+
 // Get the type.
 
 Type*
@@ -2096,6 +2125,15 @@ String_expression::do_traverse(Traverse* traverse)
   return TRAVERSE_CONTINUE;
 }
 
+bool
+String_expression::do_is_untyped(Type** ptype) const
+{
+  if (this->type_ != NULL)
+return Expression::is_untyped_type(this->type_, ptype);
+  *ptype = Type::make_string_type();
+  return true;
+}
+
 // Get the type.
 
 Type*
@@ -2485,6 +2523,9 @@ class Integer_expression : public Expression
   do_is_constant() const
   { return true; }
 
+  bool
+  do_is_untyped(Type**) const;
+
   bool
   do_is_zero_value() const
   { return mpz_sgn(this->val_) == 0; }
@@ -2568,6 +2609,18 @@ 
Integer_expression::do_numeric_constant_value(Numeric_constant* nc) const
   return true;
 }
 
+bool
+Integer_expression::do_is_untyped(Type** ptype) const
+{
+  if (this->type_ != NULL)
+return Expression::is_untyped_type(this->type_, ptype);
+  if (this->is_character_constant_)
+*ptype = Type::make_abstract_character_type();
+  else
+*ptype = Type::make_abstract_integer_type();
+  return true;
+}
+
 // Return the current type.  If we haven't set the type yet, we return
 // an abstract integer type.
 
@@ -2913,6 +2966,9 @@ class Float_expression : public Expression
   do_is_constant() const
   { return true; }
 
+  bool
+  do_is_untyped(Type**) const;
+
   bool
   do_is_zero_value() const
   {
@@ -2979,6 +3035,15 @@ Float_expression::do_traverse(Traverse* traverse)
   return TRAVERSE_CONTINUE;
 }
 
+bool
+Float_expression::do_is_untyped(Type** ptype) const
+{
+  if (this->type_ != NULL)
+return Expression::is_untyped_type(this->type_, ptype);
+  *ptype = Type::make_abstract_float_type();
+  return true;
+}
+
 // Return the current type.  If we haven't set the type yet, we return
 // an abstract float type.
 
@@ -3135,6 +3200,9 @@ class Complex_expression : public Expression
   do_is_constant() const
   { return true; }
 
+  bool
+  do_is_untyped(Type**) const;
+
   bool
   do_is_zero_value() const
   {
@@ -3205,6 +3273,15 @@ Complex_expression::do_traverse(Traverse* traverse)
   return TRAVERSE_CONTINUE;
 }
 
+bool
+Complex_expression::do_is_untyped(Type** ptype) const
+{
+  if (this->type_ != NULL)
+return Expression::is_untyped_type(this->type_, ptype);
+  *ptype = Type::make_abstract_complex_type();
+  return true;
+}
+
 // Return the current type.  If we haven't set the type yet, we return
 // an abstract complex type.
 
@@ -3458,6 +3535,21 @@ Const_expression::do_boolean_constant_value(bool* val) 
const
   return ok;
 }
 
+// Whether this is untyped.
+
+bool
+Const_expression::do_is_untyped(Type** ptype) const
+{
+  if (this->type_ != NULL)
+return Expression::is_untyped_type(this->type_, ptype);
+
+  Named_constant* nc = this->constant_->const_value();
+  if (nc->type() != NULL)
+return Expression::is_untyped_type(nc->type(), ptype);
+
+ 

Go patch committed: Pass Gogo to Runtime::make_call

2023-10-23 Thread Ian Lance Taylor
This Go frontend patches passes the Gogo IR pointer to
Runtime::make_call.  This is a boilerplate change that doesn't affect
compiler output.  It's not currently used but will be used by later
CLs in this series.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
45a5ab0503569e57883dca4d8e76d83dc3a60ff6
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index d4095637cea..d962c4f5770 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-1c0a7c9338801d15afba7e39109554ed3406654e
+806217827fe30553d535f876f182a9e92f5f648e
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 5bea6238def..c7b442d3a03 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -305,8 +305,8 @@ Expression::convert_for_assignment(Gogo* gogo, Type* 
lhs_type,
 {
   // Type to interface conversions have been made explicit early.
   go_assert(rhs_type->interface_type() != NULL);
-  return Expression::convert_interface_to_interface(lhs_type, rhs, false,
-location);
+  return Expression::convert_interface_to_interface(gogo, lhs_type, rhs,
+   false, location);
 }
   else if (!are_identical && rhs_type->interface_type() != NULL)
 return Expression::convert_interface_to_type(gogo, lhs_type, rhs, 
location);
@@ -525,7 +525,8 @@ Expression::get_interface_type_descriptor(Expression* rhs)
 // interface type.
 
 Expression*
-Expression::convert_interface_to_interface(Type *lhs_type, Expression* rhs,
+Expression::convert_interface_to_interface(Gogo* gogo, Type *lhs_type,
+  Expression* rhs,
bool for_type_guard,
Location location)
 {
@@ -558,7 +559,7 @@ Expression::convert_interface_to_interface(Type *lhs_type, 
Expression* rhs,
   if (for_type_guard)
 {
   // A type assertion fails when converting a nil interface.
-  first_field = Runtime::make_call(Runtime::ASSERTITAB, location, 2,
+  first_field = Runtime::make_call(gogo, Runtime::ASSERTITAB, location, 2,
   lhs_type_expr, rhs_type_expr);
 }
   else if (lhs_is_empty)
@@ -571,7 +572,7 @@ Expression::convert_interface_to_interface(Type *lhs_type, 
Expression* rhs,
 {
   // A conversion to a non-empty interface may fail, but unlike a
   // type assertion converting nil will always succeed.
-  first_field = Runtime::make_call(Runtime::REQUIREITAB, location, 2,
+  first_field = Runtime::make_call(gogo, Runtime::REQUIREITAB, location, 2,
   lhs_type_expr, rhs_type_expr);
 }
 
@@ -610,7 +611,7 @@ Expression::convert_interface_to_type(Gogo* gogo, Type 
*lhs_type, Expression* rh
 
   Expression* cond;
   if (gogo->need_eqtype()) {
-cond = Runtime::make_call(Runtime::EQTYPE, location,
+cond = Runtime::make_call(gogo, Runtime::EQTYPE, location,
   2, lhs_type_expr,
   rhs_descriptor);
   } else {
@@ -619,7 +620,7 @@ Expression::convert_interface_to_type(Gogo* gogo, Type 
*lhs_type, Expression* rh
   }
 
   rhs_descriptor = Expression::get_interface_type_descriptor(rhs);
-  Expression* panic = Runtime::make_call(Runtime::PANICDOTTYPE, location,
+  Expression* panic = Runtime::make_call(gogo, Runtime::PANICDOTTYPE, location,
  3, lhs_type_expr->copy(),
  rhs_descriptor,
  rhs_inter_expr);
@@ -719,7 +720,8 @@ 
Expression::backend_numeric_constant_expression(Translate_context* context,
 // functions, which will panic.
 
 void
-Expression::check_bounds(Expression* val, Operator op, Expression* bound,
+Expression::check_bounds(Gogo* gogo, Expression* val, Operator op,
+Expression* bound,
 Runtime::Function code,
 Runtime::Function code_u,
 Runtime::Function code_extend,
@@ -813,7 +815,7 @@ Expression::check_bounds(Expression* val, Operator op, 
Expression* bound,
 }
 
   Expression* ignore = Expression::make_boolean(true, loc);
-  Expression* crash = Runtime::make_call(c, loc, 2,
+  Expression* crash = Runtime::make_call(gogo, c, loc, 2,
 val->copy(), bound->copy());
   Expression* cond = Expression::make_conditional(check, ignore, crash, loc);
   inserter->insert(Statement::make_statement(cond, true));
@@ -3916,7 +3918,7 @@ Type_conversion_expression::do_traverse(Traverse* 
traverse)
 // from slice to pointer-to-array, as they can panic.
 
 Expression*
-Type_conver

Go patch committed: Make xx_constant_value methods non-const

2023-10-23 Thread Ian Lance Taylor
This patch to the Go frontend changes the Expression
{numeric,string,boolean}_constant_value methods to be non-const.  This
does not affect anything immediately, but will be useful for later CLs
in this series.

The only real effect is to Builtin_call_expression::do_export, which
remains const and can no longer call numeric_constant_value.  But it
never needed to call it, as do_export runs after do_lower, and
do_lower replaces a constant expression with the actual constant.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
597dba85b3e66a0836dd7442edcc2fda7e0703fc
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index d962c4f5770..35b9cd780da 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-806217827fe30553d535f876f182a9e92f5f648e
+3c2a441ef6cafb018bb3cc16f8403ae3d1daf2e1
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index c7b442d3a03..f218731041b 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -846,7 +846,7 @@ class Error_expression : public Expression
   { return false; }
 
   bool
-  do_numeric_constant_value(Numeric_constant* nc) const
+  do_numeric_constant_value(Numeric_constant* nc)
   {
 nc->set_unsigned_long(NULL, 0);
 return true;
@@ -1992,7 +1992,7 @@ class Boolean_expression : public Expression
   { return this->val_ == false; }
 
   bool
-  do_boolean_constant_value(bool* val) const
+  do_boolean_constant_value(bool* val)
   {
 *val = this->val_;
 return true;
@@ -2537,7 +2537,7 @@ class Integer_expression : public Expression
   { return true; }
 
   bool
-  do_numeric_constant_value(Numeric_constant* nc) const;
+  do_numeric_constant_value(Numeric_constant* nc);
 
   Type*
   do_type();
@@ -2602,7 +2602,7 @@ Integer_expression::do_traverse(Traverse* traverse)
 // this as a character when appropriate.
 
 bool
-Integer_expression::do_numeric_constant_value(Numeric_constant* nc) const
+Integer_expression::do_numeric_constant_value(Numeric_constant* nc)
 {
   if (this->is_character_constant_)
 nc->set_rune(this->type_, this->val_);
@@ -2983,7 +2983,7 @@ class Float_expression : public Expression
   { return true; }
 
   bool
-  do_numeric_constant_value(Numeric_constant* nc) const
+  do_numeric_constant_value(Numeric_constant* nc)
   {
 nc->set_float(this->type_, this->val_);
 return true;
@@ -3219,7 +3219,7 @@ class Complex_expression : public Expression
   { return true; }
 
   bool
-  do_numeric_constant_value(Numeric_constant* nc) const
+  do_numeric_constant_value(Numeric_constant* nc)
   {
 nc->set_complex(this->type_, this->val_);
 return true;
@@ -3480,7 +3480,7 @@ Const_expression::do_lower(Gogo* gogo, Named_object*,
 // Return a numeric constant value.
 
 bool
-Const_expression::do_numeric_constant_value(Numeric_constant* nc) const
+Const_expression::do_numeric_constant_value(Numeric_constant* nc)
 {
   if (this->seen_)
 return false;
@@ -3508,7 +3508,7 @@ 
Const_expression::do_numeric_constant_value(Numeric_constant* nc) const
 }
 
 bool
-Const_expression::do_string_constant_value(std::string* val) const
+Const_expression::do_string_constant_value(std::string* val)
 {
   if (this->seen_)
 return false;
@@ -3523,7 +3523,7 @@ Const_expression::do_string_constant_value(std::string* 
val) const
 }
 
 bool
-Const_expression::do_boolean_constant_value(bool* val) const
+Const_expression::do_boolean_constant_value(bool* val)
 {
   if (this->seen_)
 return false;
@@ -4180,7 +4180,7 @@ Type_conversion_expression::do_is_static_initializer() 
const
 
 bool
 Type_conversion_expression::do_numeric_constant_value(
-Numeric_constant* nc) const
+Numeric_constant* nc)
 {
   if (!this->type_->is_numeric_type())
 return false;
@@ -4192,7 +4192,7 @@ Type_conversion_expression::do_numeric_constant_value(
 // Return the constant string value if there is one.
 
 bool
-Type_conversion_expression::do_string_constant_value(std::string* val) const
+Type_conversion_expression::do_string_constant_value(std::string* val)
 {
   if (this->type_->is_string_type() && this->expr_->type()->is_string_type())
 return this->expr_->string_constant_value(val);
@@ -4229,7 +4229,7 @@ 
Type_conversion_expression::do_string_constant_value(std::string* val) const
 // Return the constant boolean value if there is one.
 
 bool
-Type_conversion_expression::do_boolean_constant_value(bool* val) const
+Type_conversion_expression::do_boolean_constant_value(bool* val)
 {
   if (!this->type_->is_boolean_type())
 return false;
@@ -5141,7 +5141,7 @@ Unary_expression::eval_constant(Operator op, const 
Numeric_constant* unc,
 // Return the integral constant value of a unary expression, if it has one.
 
 bool
-Unary_expression::do_numeric_constant_value(Numeric_constant* nc) const
+Unary_expression::do_num

Go patch committed: Move Selector_expression up in file

2023-10-23 Thread Ian Lance Taylor
This patch to the Go frontend just moves Selector_expression up in
file.  This is a mechanical change to expressions.cc.  This will make
Selector_expression visible to Builtin_call_expression for later work.
This produces a very large "git --diff", but "git diff --minimal" is
clear.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
02aa322c8cfd3f60fa5a3a0eee4340bb644261fe
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 35b9cd780da..aff74bd74dc 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-3c2a441ef6cafb018bb3cc16f8403ae3d1daf2e1
+e997b0201512110e9c20b1fdfd40014830031047
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index f218731041b..c9177b71174 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -8426,6 +8426,287 @@ Expression::make_bound_method(Expression* expr, const 
Method* method,
   return new Bound_method_expression(expr, method, function, location);
 }
 
+// A general selector.  This is a Parser_expression for LEFT.NAME.  It
+// is lowered after we know the type of the left hand side.
+
+class Selector_expression : public Parser_expression
+{
+ public:
+  Selector_expression(Expression* left, const std::string& name,
+ Location location)
+: Parser_expression(EXPRESSION_SELECTOR, location),
+  left_(left), name_(name)
+  { }
+
+ protected:
+  int
+  do_traverse(Traverse* traverse)
+  { return Expression::traverse(&this->left_, traverse); }
+
+  Expression*
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
+
+  Expression*
+  do_copy()
+  {
+return new Selector_expression(this->left_->copy(), this->name_,
+  this->location());
+  }
+
+  void
+  do_dump_expression(Ast_dump_context* ast_dump_context) const;
+
+ private:
+  Expression*
+  lower_method_expression(Gogo*);
+
+  // The expression on the left hand side.
+  Expression* left_;
+  // The name on the right hand side.
+  std::string name_;
+};
+
+// Lower a selector expression once we know the real type of the left
+// hand side.
+
+Expression*
+Selector_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*,
+ int)
+{
+  Expression* left = this->left_;
+  if (left->is_type_expression())
+return this->lower_method_expression(gogo);
+  return Type::bind_field_or_method(gogo, left->type(), left, this->name_,
+   this->location());
+}
+
+// Lower a method expression T.M or (*T).M.  We turn this into a
+// function literal.
+
+Expression*
+Selector_expression::lower_method_expression(Gogo* gogo)
+{
+  Location location = this->location();
+  Type* left_type = this->left_->type();
+  Type* type = left_type;
+  const std::string& name(this->name_);
+
+  bool is_pointer;
+  if (type->points_to() == NULL)
+is_pointer = false;
+  else
+{
+  is_pointer = true;
+  type = type->points_to();
+}
+
+  Named_type* nt = type->named_type();
+  Struct_type* st = type->struct_type();
+  bool is_ambiguous;
+  Method* method = NULL;
+  if (nt != NULL)
+method = nt->method_function(name, &is_ambiguous);
+  else if (st != NULL)
+method = st->method_function(name, &is_ambiguous);
+  const Typed_identifier* imethod = NULL;
+  if (method == NULL && !is_pointer)
+{
+  Interface_type* it = type->interface_type();
+  if (it != NULL)
+   imethod = it->find_method(name);
+}
+
+  if ((method == NULL && imethod == NULL)
+  || (left_type->named_type() != NULL && left_type->points_to() != NULL))
+{
+  if (nt != NULL)
+   {
+ if (!is_ambiguous)
+   go_error_at(location, "type %<%s%s%> has no method %<%s%>",
+   is_pointer ? "*" : "",
+   nt->message_name().c_str(),
+   Gogo::message_name(name).c_str());
+ else
+   go_error_at(location, "method %<%s%s%> is ambiguous in type %<%s%>",
+   Gogo::message_name(name).c_str(),
+   is_pointer ? "*" : "",
+   nt->message_name().c_str());
+   }
+  else
+   {
+ if (!is_ambiguous)
+   go_error_at(location, "type has no method %<%s%>",
+   Gogo::message_name(name).c_str());
+ else
+   go_error_at(location, "method %<%s%> is ambiguous",
+   Gogo::message_name(name).c_str());
+   }
+  return Expression::make_error(location);
+}
+
+  if (method != NULL && !is_pointer && !method->is_value_method())
+{
+  go_error_at(location, "method requires pointer (use %<(*%s).%s%>)",
+  nt->message_name().c_str(),
+  Gogo::message_name(name).c_str());
+  return Expression::make_error(l

Re: [PATCH] testsuite: Fix _BitInt in gcc.misc-tests/godump-1.c

2023-10-25 Thread Ian Lance Taylor
On Tue, Oct 24, 2023, 11:03 AM Jeff Law  wrote:

>
>
> On 10/24/23 09:26, Stefan Schulze Frielinghaus wrote:
> > Currently _BitInt is only supported on x86_64 which means that for other
> > targets all tests fail with e.g.
> >
> > gcc.misc-tests/godump-1.c:237:1: sorry, unimplemented: '_BitInt(32)' is
> not supported on this target
> >237 | _BitInt(32) b32_v;
> >| ^~~
> >
> > Instead of requiring _BitInt support for godump-1.c, move _BitInt tests
> > into godump-2.c such that all other tests in godump-1.c are still
> > executed in case of missing _BitInt support.
> >
> > Tested on s390x and x86_64.  Ok for mainline?
> >
> > gcc/testsuite/ChangeLog:
> >
> >   * gcc.misc-tests/godump-1.c: Move _BitInt tests into godump-2.c.
> >   * gcc.misc-tests/godump-2.c: New test.
> OK
>

Thanks.

Ian

>


libstdc++ patch RFA: Fix dl_iterate_phdr configury for libbacktrace

2023-11-02 Thread Ian Lance Taylor
The libbacktrace sources, as used by libstdc++-v3, fail to correctly
determine whether the system supports dl_iterate_phdr.  The issue is
that the libbacktrace configure assumes that _GNU_SOURCE is defined
during compilation, but the libstdc++-v3 configure does not do that.
This configury failure is the cause of PR 112263.

This patch fixes the problem.  OK for mainline?

Ian

PR libbacktrace/112263
* acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when
grepping link.h for dl_iterate_phdr.
* configure: Regenerate.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index d8f0ba1c3e2..41446c2c3d6 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -5443,7 +5443,7 @@ AC_DEFUN([GLIBCXX_ENABLE_BACKTRACE], [
 
   # Most of this is adapted from libsanitizer/configure.ac
 
-  BACKTRACE_CPPFLAGS=
+  BACKTRACE_CPPFLAGS="-D_GNU_SOURCE"
 
   # libbacktrace only needs atomics for int, which we've already tested
   if test "$glibcxx_cv_atomic_int" = "yes"; then
@@ -5471,8 +5471,11 @@ AC_DEFUN([GLIBCXX_ENABLE_BACKTRACE], [
 have_dl_iterate_phdr=no
   else
 # When built as a GCC target library, we can't do a link test.
+ac_save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
[have_dl_iterate_phdr=no])
+CPPFLAGS="$ac_save_CPPFLAGS"
   fi
   if test "$have_dl_iterate_phdr" = "yes"; then
 BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_DL_ITERATE_PHDR=1"
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 9f12c5baa3f..693564d3c7e 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -73299,7 +73299,7 @@ fi
 
   # Most of this is adapted from libsanitizer/configure.ac
 
-  BACKTRACE_CPPFLAGS=
+  BACKTRACE_CPPFLAGS="-D_GNU_SOURCE"
 
   # libbacktrace only needs atomics for int, which we've already tested
   if test "$glibcxx_cv_atomic_int" = "yes"; then
@@ -73382,6 +73382,8 @@ done
 have_dl_iterate_phdr=no
   else
 # When built as a GCC target library, we can't do a link test.
+ac_save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
@@ -73395,6 +73397,7 @@ else
 fi
 rm -f conftest*
 
+CPPFLAGS="$ac_save_CPPFLAGS"
   fi
   if test "$have_dl_iterate_phdr" = "yes"; then
 BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_DL_ITERATE_PHDR=1"


Re: [PATCH][stage1] Remove conditionals around free()

2023-03-01 Thread Ian Lance Taylor
Bernhard Reutner-Fischer  writes:

>  libgo/runtime/go-setenv.c|6 ++
>  libgo/runtime/go-unsetenv.c  |3 +--

Files in the libgo directory are mirrored from upstream sources, as
described in libgo/README.gcc.  Please don't change them in the gcc
repository.  Thanks.

Ian


Re: Patch ping: Re: [PATCH] libgcc, i386, optabs, v2: Add __float{, un}tibf to libgcc and expand BF -> integral through SF intermediate [PR107703]

2023-03-10 Thread Ian Lance Taylor
Jakub Jelinek  writes:

> On Wed, Mar 01, 2023 at 01:32:43PM +0100, Jakub Jelinek via Gcc-patches wrote:
>> On Wed, Nov 16, 2022 at 12:51:14PM +0100, Jakub Jelinek via Gcc-patches 
>> wrote:
>> > On Wed, Nov 16, 2022 at 10:06:17AM +0100, Jakub Jelinek via
>> > Gcc-patches wrote:
>> > > Thoughts on this?  I guess my preference would be the BF -> SF -> TI
>> > > path because we won't need to waste
>> > > 32: 00015e10 321 FUNC GLOBAL DEFAULT 13
>> > > __fixbfti@@GCC_13.0.0
>> > > 89: 00015f60 299 FUNC GLOBAL DEFAULT 13
>> > > __fixunsbfti@@GCC_13.0.0
>> > > If so, I'd need to cut the fix parts of the patch below and
>> > > do something in the middle-end.
>> > 
>> > Here is adjusted patch that does that.
>> > 
>> > 2022-11-16  Jakub Jelinek  
>> > 
>> >PR target/107703
>> >* optabs.cc (expand_fix): For conversions from BFmode to integral,
>> >use shifts to convert it to SFmode first and then convert SFmode
>> >to integral.
>> > 
>> >* soft-fp/floattibf.c: New file.
>> >* soft-fp/floatuntibf.c: New file.
>> >* config/i386/libgcc-glibc.ver: Export __float{,un}tibf @ GCC_13.0.0.
>> >* config/i386/64/t-softfp (softfp_extras): Add floattibf and
>> >floatuntibf.
>> >(CFLAGS-floattibf.c, CFLAGS-floatunstibf.c): Add -msse2.
>> 
>> I'd like to ping the libgcc non-i386 part of this patch, Uros said the i386
>> part is ok but that one depends on the generic libgcc changes.
>> I'll ping the optabs.cc change separately.
>> 
>> https://gcc.gnu.org/pipermail/gcc-patches/2022-November/606398.html
>> with more info in
>> https://gcc.gnu.org/pipermail/gcc-patches/2022-November/606382.html
>
> I'd like to ping this again.  I've posted the previously added
> bfloat16 changes as well as the above 2 new files to libc-alpha as well
> https://sourceware.org/pipermail/libc-alpha/2023-March/146246.html
> if it makes the review easier.


The libgcc parts of this are fine.  Thanks.

Ian


Re: ***SPAM*** [PATCH] libgcc: allocate extra space for morestack expansion

2021-02-10 Thread Ian Lance Taylor
Rain Mark  writes:

> After enabling -fsplit-stack, dynamic stack expansion of the coroutine
> is realized, but calling functions without -fsplit-stack will directly
> expand the space by 1M, which is too wasteful for a system with a large
> number of coroutines running under the 128K stack size. We hope to give
> users more control over the size of stack expansion to adapt to
> more complex scenarios.
>
> Apply for more space each time the stack is expanded, which
> can also reduce the frequency of morestack being called.
> When calling the non-split function, we do not need additional
> checks and apply for 1M space.  At this time, we can turn off
> the conversion of linker to __morestack_non_split.  This is more friendly
> to a large number of small stack coroutines running below 128K.
>
> Later we need to add an option to the gold linker to turn off
> the __morestack_non_split conversion.

Why is the new variable thread local?

At first glance it seems like this might make more sense as a compiler
option or compiler function attribute, rather than as a function to
call.  When would you want to dynamically change the value?

Ian


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

2019-10-25 Thread Ian Lance Taylor
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
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 0x10;
+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 0x10;
+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 0x10;
+return 2;
+  }
 
   void
   do_export(Export_function_body*) const;


Merge from trunk to gccgo branch

2019-10-25 Thread Ian Lance Taylor
I merged trunk revision 277462 to the gccgo branch.

Ian


Re: [golang-dev] [PATCH 0/4] Fix library testsuite compilation for build sysroot

2019-11-11 Thread Ian Lance Taylor
On Mon, Nov 11, 2019 at 10:15 AM Ulderico Cirello
 wrote:
>
> Go's project doesn't take mail patches for changes. Please use gerrit ( 
> https://go-review.googlesource.com/ ).

These patches are for gccgo, not the gc toolchain.  They should
probably have been sent to gofrontend-dev rather than golang-dev.  The
gccgo repo does take patches via e-mail; I route them through Gerrit
as needed.

Ian


Re: [golang-dev] [PATCH 0/4] Fix library testsuite compilation for build sysroot

2019-11-11 Thread Ian Lance Taylor
On Mon, Nov 11, 2019 at 10:31 AM Kaz Kylheku (libffi)
<382-725-6...@kylheku.com> wrote:
>
> On 2019-11-11 10:15, Ulderico Cirello wrote:
> > Hi Maciej,
> >
> > Go's project doesn't take mail patches for changes.
>
> Is it that they'd have to read man pages and learn how to use common
> utilities?
>
> Or that nobody has written a "patch in Go" yet?

Please be polite; thanks.  There are many advantages to using Gerrit
for code review.  It has nothing to do with reading man pages or using
the patch program.

Ian


Re: [golang-dev] [PATCH 0/4] Fix library testsuite compilation for build sysroot

2019-11-11 Thread Ian Lance Taylor
On Mon, Nov 11, 2019 at 10:44 AM Maciej W. Rozycki  wrote:
>
> On Mon, 11 Nov 2019, Ian Lance Taylor wrote:
>
> > > Go's project doesn't take mail patches for changes. Please use gerrit ( 
> > > https://go-review.googlesource.com/ ).
> >
> > These patches are for gccgo, not the gc toolchain.  They should
> > probably have been sent to gofrontend-dev rather than golang-dev.  The
> > gccgo repo does take patches via e-mail; I route them through Gerrit
> > as needed.
>
>  I may have misinterpreted this paragraph[1]:
>
> "Submitting Changes
>
>Changes to the Go frontend should follow the same process as for the
>main Go repository, only for the gofrontend project and the
>gofrontend-...@googlegroups.com mailing list rather than the go project
>and the golang-...@googlegroups.com mailing list. Those changes will
>then be merged into the GCC sources."
>
> Sorry about that; I think it might benefit from a rewrite for clarity
> though.
>
> References:
>
> [1] "Contributing to the gccgo frontend - The Go Programming Language",
> <https://golang.org/doc/gccgo_contribute.html>


The paragraph seems reasonable clear to me, so I'm obviously missing
something.  Can you suggest a clearer rewrite?  Thanks.

Ian


Re: [golang-dev] [PATCH 3/4] libgo/test: Fix compilation for build sysroot

2019-11-11 Thread Ian Lance Taylor
On Mon, Nov 11, 2019 at 10:12 AM Maciej W. Rozycki  wrote:
>
> Fix a problem with the libgo testsuite using a method to determine the
> compiler to use resulting in the tool being different from one the
> library has been built with, and causing a catastrophic failure from the
> lack of a suitable `--sysroot=' option where the `--with-build-sysroot='
> configuration option has been used to build the compiler resulting in
> the inability to link executables.
>
> Address this problem by providing a DejaGNU configuration file defining
> the compiler to use, via the GOC_UNDER_TEST TCL variable, set from $GOC
> by autoconf, which will have all the required options set for the target
> compiler to build executables in the environment configured, removing
> failures like:
>
> .../bin/riscv64-linux-gnu-ld: cannot find crt1.o: No such file or directory
> .../bin/riscv64-linux-gnu-ld: cannot find -lm
> .../bin/riscv64-linux-gnu-ld: cannot find -lc
> collect2: error: ld returned 1 exit status
> compiler exited with status 1
>
> No summary comparison, because the libgo testsuite does not provide one
> in this configuration for some reason, however this change improves
> overall test results for the `riscv64-linux-gnu' target (here with the
> `x86_64-linux-gnu' host and RISC-V QEMU in the Linux user emulation mode
> as the target board) from 0 PASSes and 159 FAILs to 133 PASSes and 26
> FAILs.
>
> libgo/
> * configure.ac: Add testsuite/libgo-test-support.exp to output
> files.
> * configure: Regenerate.
> * testsuite/libgo-test-support.exp.in: New file.
> * testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New
> variable.
> * testsuite/Makefile.in: Regenerate.
> * testsuite/lib/libgo.exp: Don't override GOC_UNDER_TEST
> previously set.

Thanks.

Committed to mainline.

Ian


Re: [golang-dev] [PATCH] libgo/test: Add flags to find libgcc_s in build-tree testing

2019-11-11 Thread Ian Lance Taylor
[ moving from golang-dev to gofrontend-dev ]

On Mon, Nov 11, 2019 at 7:48 AM Maciej W. Rozycki  wrote:
>
> Add a setting for the dynamic loader to find the shared libgcc_s library
> in build-tree testing, fixing a catastrophic libgo testsuite failure in
> cross-compilation where the library cannot be found by the loader at run
> time and consequently no test case executes, producing output (here with
> the `x86_64-linux-gnu' host and the `riscv64-linux-gnu' target, with
> RISC-V QEMU in the Linux user emulation mode as the target board) like:
>
> spawn qemu-riscv64 -E 
> LD_LIBRARY_PATH=.:.../riscv64-linux-gnu/lib64/lp64d/libgo/.libs ./a.exe
> ./a.exe: error while loading shared libraries: libgcc_s.so.1: cannot open 
> shared object file: No such file or directory
> FAIL: archive/tar
>
> Use the `ld_library_path' TCL variable to propagate the setting obtained
> from where GCC finds the library at link time, making test output look
> like:
>
> spawn qemu-riscv64 -E 
> LD_LIBRARY_PATH=.:..././gcc/lib64/lp64d:.../riscv64-linux-gnu/lib64/lp64d/libgo/.libs
>  ./a.exe
> PASS
> PASS: archive/tar
>
> No summary comparison, because the libgo testsuite does not provide one
> in this configuration for some reason, however this change improves
> overall results from 0 PASSes and 159 FAILs to 133 PASSes and 26 FAILs.
>
> gcc/testsuite/
> * lib/go.exp (go_link_flags): Add `ld_library_path' setting to
> find shared `libgcc_s' library at run time in build-tree
> testing.

Is there similar code for other languages, such as Fortran?  I don't
see why Go would be different here.



>  Regression-tested with `make check-go' with the `x86_64-linux-gnu' native
> system as well as the `x86_64-linux-gnu' host and the `riscv64-linux-gnu'
> target, with RISC-V QEMU in the Linux user emulation mode as the target
> board.
>
>  NB as a heads-up numerous tests fail quietly (i.e. with no FAIL report
> and no name of the test case given either) to link due to unsatisfied
> symbol references, such as:
>
> .../bin/riscv64-linux-gnu-ld: _gotest_.o: in function 
> `cmd..z2fgo..z2finternal..z2fcache.Cache.get':
> .../riscv64-linux-gnu/libgo/gotest24771/test/cache.go:182: undefined 
> reference to `cmd..z2fgo..z2finternal..z2frenameio.ReadFile'
>
> which I take is due to a reference to `libgotool.a' -- which is where the
> required symbols are defined -- missing from the linker invocation.  I
> don't know what's supposed to supply the library to the linker or whether
> this indeed the actual cause; I find the way libgo tests have been wired
> unusual and consequently hard to follow, so maybe someone more familiar
> with this stuff will be able to tell what is going on here.  I'll be happy
> to push any patches through testing.

(That is, of course, a libgo test failure, and as such is not affected
by your patch to go.exp.)

In normal usage, that test is linked against libgotool.a because of
the variable extra_check_libs_cmd_go_internal_cache in
libgo/Makefile.am.  That variable is added to GOLIBS in the CHECK
variable in libgo/Makefile.am.  Maybe the fix is for
libgo/testsuite/lib/libgo.exp to use GOLIBS.

Ian


Re: [C++ coroutines 6/7] libiberty demangler update.

2020-01-09 Thread Ian Lance Taylor
Iain Sandoe  writes:

> The coroutines implementation introduces a new operator with a
> mangling of 'aw'.  This patch adds that to libiberty's demangler.
>
> Although this is presented as part of the coroutines patch series
> it could stand alone, since clang and EDG-based compilers are
> already emitting this mangling.
>
> I tested this with a binutils build (using the built c++filt).
>
> OK for trunk?
> Iain
>
> libiberty/ChangeLog:
>
> 2020-01-09  Iain Sandoe  
>
>   * cp-demangle.c (cplus_demangle_operators): Add the co_await
>   operator.

Please add something to libiberty/testsuite/demangle-expected.  Thanks.

Ian


Go patch committed: Don't add composite literal keys to package bindings

2020-01-09 Thread Ian Lance Taylor
This patch to the Go frontend avoids adding composite literal keys to
the package bindings.  Doing this gets confusing when it is combined
with dot imports.  The test case showing the resulting compilation
failure is https://golang.org/cl/213899.

Fix this by adding a new expression type to hold composite literal
keys.  We shouldn't see it during lowering if it is a struct field
name, because Composite_literal_expression::do_traverse skips struct
field names.  Or, it should, but that didn't quite work with pointer
types so it had to be tweaked.

This lets us remove the code that recorded whether an
Unknown_expression is a composite literal key.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279984)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-e0790a756e9ba77e2d3d6ef5d0abbb11dd71211b
+8ad32fb3e1e8b19ac125d03db24a73a800abdfa6
 
 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 279979)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -1761,8 +1761,6 @@ Unknown_expression::do_lower(Gogo*, Name
   real = no->unknown_value()->real_named_object();
   if (real == NULL)
{
- if (this->is_composite_literal_key_)
-   return this;
  if (!this->no_error_message_)
go_error_at(location, "reference to undefined name %qs",
this->named_object_->message_name().c_str());
@@ -1776,8 +1774,6 @@ Unknown_expression::do_lower(Gogo*, Name
 case Named_object::NAMED_OBJECT_TYPE:
   return Expression::make_type(real->type_value(), location);
 case Named_object::NAMED_OBJECT_TYPE_DECLARATION:
-  if (this->is_composite_literal_key_)
-   return this;
   if (!this->no_error_message_)
go_error_at(location, "reference to undefined type %qs",
real->message_name().c_str());
@@ -1789,8 +1785,6 @@ Unknown_expression::do_lower(Gogo*, Name
 case Named_object::NAMED_OBJECT_FUNC_DECLARATION:
   return Expression::make_func_reference(real, NULL, location);
 case Named_object::NAMED_OBJECT_PACKAGE:
-  if (this->is_composite_literal_key_)
-   return this;
   if (!this->no_error_message_)
go_error_at(location, "unexpected reference to package");
   return Expression::make_error(location);
@@ -15992,6 +15986,77 @@ Map_construction_expression::do_dump_exp
   ast_dump_context->ostream() << "}";
 }
 
+// A composite literal key.  This is seen during parsing, but is not
+// resolved to a named_object in case this is a composite literal of
+// struct type.
+
+class Composite_literal_key_expression : public Parser_expression
+{
+ public:
+  Composite_literal_key_expression(const std::string& name, Location location)
+: Parser_expression(EXPRESSION_COMPOSITE_LITERAL_KEY, location),
+  name_(name)
+  { }
+
+  const std::string&
+  name() const
+  { return this->name_; }
+
+ protected:
+  Expression*
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
+
+  Expression*
+  do_copy()
+  {
+return new Composite_literal_key_expression(this->name_, this->location());
+  }
+
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
+ private:
+  // The name.
+  std::string name_;
+};
+
+// Lower a composite literal key.  We will never get here for keys in
+// composite literals of struct types, because that is prevented by
+// Composite_literal_expression::do_traverse.  So if we do get here,
+// this must be a regular name reference after all.
+
+Expression*
+Composite_literal_key_expression::do_lower(Gogo* gogo, Named_object*,
+  Statement_inserter*, int)
+{
+  Named_object* no = gogo->lookup(this->name_, NULL);
+  if (no == NULL)
+{
+  go_error_at(this->location(), "reference to undefined name %qs",
+ Gogo::message_name(this->name_).c_str());
+  return Expression::make_error(this->location());
+}
+  return Expression::make_unknown_reference(no, this->location());
+}
+
+// Dump a composite literal key.
+
+void
+Composite_literal_key_expression::do_dump_expression(
+Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "_UnknownName_(" << this->name_ << ")";
+}
+
+// Make a composite literal key.
+
+Expression*
+Expression::make_composite_literal_key(const std::string& name,
+  Location location)
+{
+  return new Composite_literal_key_expression(name, location);
+}
+
 // Class Composite_literal_expression.
 
 // Traversal.
@@ -16013,6 +16078,7 @@ Composite_literal_expression::do_travers
 
   for (int depth = 0; depth < this->

Go patch committed: Don't localize names in export data

2020-01-09 Thread Ian Lance Taylor
This patch changes the Go frontend to not localize names in export
data.  Localizing these names causes the compiler output to change
depending on the LANG environment variable, so don't do it.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 280056)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-8ad32fb3e1e8b19ac125d03db24a73a800abdfa6
+f9d1bfb3eec2d388c5f239779fd25a580064dd9d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/export.cc
===
--- gcc/go/gofrontend/export.cc (revision 279815)
+++ gcc/go/gofrontend/export.cc (working copy)
@@ -1231,7 +1231,7 @@ Export::write_name(const std::string& na
   if (name.empty())
 this->write_c_string("?");
   else
-this->write_string(Gogo::message_name(name));
+this->write_string(Gogo::unpack_hidden_name(name));
 }
 
 // Write an integer value to the export stream.


libgo patch committed: Compile examples in _test packages

2020-01-09 Thread Ian Lance Taylor
This libgo patch compiles examples in _test packages.  Previously if
the only names defined by _test packages were examples, the gotest
script would emit an incorrect _testmain.go file.  I worked around
that by marking the example_test.go files +build ignored.  This CL
changes the gotest script to handle this case correctly, and removes
the now-unnecessary build tags.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 280057)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-f9d1bfb3eec2d388c5f239779fd25a580064dd9d
+92ee4c2e295fc760105f187f6ea6dc65c81fa892
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/compress/flate/example_test.go
===
--- libgo/go/compress/flate/example_test.go (revision 279815)
+++ libgo/go/compress/flate/example_test.go (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package flate_test
 
 import (
Index: libgo/go/compress/gzip/example_test.go
===
--- libgo/go/compress/gzip/example_test.go  (revision 279815)
+++ libgo/go/compress/gzip/example_test.go  (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package gzip_test
 
 import (
Index: libgo/go/container/ring/example_test.go
===
--- libgo/go/container/ring/example_test.go (revision 279815)
+++ libgo/go/container/ring/example_test.go (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package ring_test
 
 import (
Index: libgo/go/crypto/sha256/example_test.go
===
--- libgo/go/crypto/sha256/example_test.go  (revision 279815)
+++ libgo/go/crypto/sha256/example_test.go  (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package sha256_test
 
 import (
Index: libgo/go/database/sql/example_cli_test.go
===
--- libgo/go/database/sql/example_cli_test.go   (revision 279815)
+++ libgo/go/database/sql/example_cli_test.go   (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package sql_test
 
 import (
Index: libgo/go/database/sql/example_service_test.go
===
--- libgo/go/database/sql/example_service_test.go   (revision 279815)
+++ libgo/go/database/sql/example_service_test.go   (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package sql_test
 
 import (
Index: libgo/go/encoding/csv/example_test.go
===
--- libgo/go/encoding/csv/example_test.go   (revision 279815)
+++ libgo/go/encoding/csv/example_test.go   (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package csv_test
 
 import (
Index: libgo/go/encoding/hex/example_test.go
===
--- libgo/go/encoding/hex/example_test.go   (revision 279815)
+++ libgo/go/encoding/hex/example_test.go   (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package hex_test
 
 import (
Index: libgo/go/encoding/json/example_marshaling_test.go
===
--- libgo/go/encoding/json/example_marshaling_test.go   (revision 279815)
+++ libgo/go/encoding/json/example_marshaling_test.go   (working copy)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore
-
 package json_test
 
 import (
Index: libgo/go/encoding/json/example_text_marshaling_test.go
===
--- libgo/go/encoding/json/example_text_marshaling_test.go  (revision 
279815)
+++ libgo/go/encoding/json/example_text_marshaling_test.go  (working copy)
@@ -2,8 +2,6 @@
 // U

Go patch committed: Permit duplicate methods from embedded interfaces

2020-01-10 Thread Ian Lance Taylor
This patch to the Go frontend permits duplicate methods from embedded
interfaces.  This is a language change for Go 1.14.  Bootstrapped and
ran Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 280085)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-92ee4c2e295fc760105f187f6ea6dc65c81fa892
+98c4c21b52afd6384f9364527bd7f5f9a1c752cf
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc  (revision 279848)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -8943,8 +8943,12 @@ Interface_type::finalize_methods()
  continue;
}
 
+  const Typed_identifier_list* imethods = it->parse_methods_;
+  if (imethods == NULL)
+   continue;
+
   Named_type* nt = t->named_type();
-  if (nt != NULL && it->parse_methods_ != NULL)
+  if (nt != NULL)
{
  std::vector::const_iterator q;
  for (q = seen.begin(); q != seen.end(); ++q)
@@ -8960,22 +8964,26 @@ Interface_type::finalize_methods()
  seen.push_back(nt);
}
 
-  const Typed_identifier_list* imethods = it->parse_methods_;
-  if (imethods == NULL)
-   continue;
   for (Typed_identifier_list::const_iterator q = imethods->begin();
   q != imethods->end();
   ++q)
{
  if (q->name().empty())
inherit.push_back(*q);
- else if (this->find_method(q->name()) == NULL)
-   this->all_methods_->push_back(Typed_identifier(q->name(),
-  q->type(), tl));
  else
-   go_error_at(tl, "inherited method %qs is ambiguous",
-Gogo::message_name(q->name()).c_str());
+   {
+ const Typed_identifier* oldm = this->find_method(q->name());
+ if (oldm == NULL)
+   this->all_methods_->push_back(Typed_identifier(q->name(),
+  q->type(), tl));
+ else if (!Type::are_identical(q->type(), oldm->type(),
+   Type::COMPARE_TAGS, NULL))
+   go_error_at(tl, "duplicate method %qs",
+   Gogo::message_name(q->name()).c_str());
+   }
}
+
+  seen.pop_back();
 }
 
   if (!this->all_methods_->empty())
Index: gcc/testsuite/go.test/test/fixedbugs/bug211.go
===
--- gcc/testsuite/go.test/test/fixedbugs/bug211.go  (revision 279815)
+++ gcc/testsuite/go.test/test/fixedbugs/bug211.go  (nonexistent)
@@ -1,14 +0,0 @@
-// errorcheck
-
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-type R interface { duplicate() }
-type S interface { duplicate() }
-type T interface { R; S }  // ERROR "duplicate"
-
-func main() {
-}
Index: gcc/testsuite/go.test/test/fixedbugs/bug251.go
===
--- gcc/testsuite/go.test/test/fixedbugs/bug251.go  (revision 279815)
+++ gcc/testsuite/go.test/test/fixedbugs/bug251.go  (working copy)
@@ -1,18 +1,18 @@
 // errorcheck
 
-// Copyright 2010 The Go Authors.  All rights reserved.
+// Copyright 2010 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
 package main
 
-type I1 interface {
+type I1 interface { // GC_ERROR "invalid recursive type"
m() I2
I2 // GCCGO_ERROR "loop|interface"
 }
 
 type I2 interface {
-   I1 // ERROR "loop|interface"
+   I1 // GCCGO_ERROR "loop|interface"
 }
 
 


Re: libgo patch committed: Compile examples in _test packages

2020-01-10 Thread Ian Lance Taylor
On Fri, Jan 10, 2020 at 5:40 AM Rainer Orth  
wrote:
>
> > This libgo patch compiles examples in _test packages.  Previously if
> > the only names defined by _test packages were examples, the gotest
> > script would emit an incorrect _testmain.go file.  I worked around
> > that by marking the example_test.go files +build ignored.  This CL
> > changes the gotest script to handle this case correctly, and removes
> > the now-unnecessary build tags.  Bootstrapped and ran Go testsuite on
> > x86_64-pc-linux-gnu.  Committed to mainline.
>
> this patch breaks quite a number of libgo tests on Solaris:
>
> FAIL: bufio
> /vol/gcc/src/hg/trunk/local/libgo/testsuite/gotest[541]: local: not found [No 
> such file or directory]

Whoops, sorry.  Fixed like so, tested and committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 280109)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-98c4c21b52afd6384f9364527bd7f5f9a1c752cf
+a69ad9c7d1b45edcf8062a07d3a3c9b6838c04f8
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/testsuite/gotest
===
--- libgo/testsuite/gotest  (revision 280109)
+++ libgo/testsuite/gotest  (working copy)
@@ -538,8 +538,7 @@ symtogo() {
 # Takes an example name and puts any output into the file example.txt.
 # It strips comment markers but does not otherwise change the output.
 exampleoutput() {
-local n=$(testname $1)
-local f
+n=$(testname $1)
 for f in $gofiles $xgofiles; do
if ! grep "^func $n(" $f >/dev/null 2>&1; then
continue


Re: [C++ coroutines 7/7] libiberty demangler update.

2020-01-11 Thread Ian Lance Taylor
Iain Sandoe  writes:

> Ian Lance Taylor  wrote:
>
>> Iain Sandoe  writes:
>
>>> 2020-01-09  Iain Sandoe  
>>> 
>>> * cp-demangle.c (cplus_demangle_operators): Add the co_await
>>> operator.
>> 
>> Please add something to libiberty/testsuite/demangle-expected.  Thanks.
>
> done***,
> OK now?
> thanks
> Iain
>
> *** it seems that the demangle test is broken for x86_64-darwin & linux on 
> trunk
> anyway, (I ‘fixed’ it locally to test my patch below; will try to figure out 
> if that fix is
> correct and post it if so) - however, that’s unconnected with the coroutines 
> stuff.
>
> ==
>
> revised:
> --
> 
> The coroutines implementation introduces a new operator with a
> mangling of 'aw'.  This patch adds that to libiberty's demangler.
> 
> libiberty/ChangeLog:
> 
> 2020-01-11  Iain Sandoe  
> 
> * cp-demangle.c (cplus_demangle_operators): Add the co_await
> operator.
> * testsuite/demangle-expected: Append a test for the co_await
> operator mangling.

This is OK.

Thanks.

Ian


Re: RFA: Fix libiberty testsuite failure

2020-01-20 Thread Ian Lance Taylor
Nick Clifton  writes:

> Hi Ian,
>
>   The libiberty testsuite in the gcc mainline is currently failing on
>   the last test:
>
> FAIL at line 1452, options :
> in:  _Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE
> out: void foo<(void*)0>(enable_if<((void*)0)==(decltype(nullptr)), 
> void>::type*)
> exp: void foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))), 
> void>::type*)
>
>   To me it looks like the expected demangling is incorrect - it wants a
>   double set of parentheses around decltype(nullptr) when I think that
>   only one is needed.  So I would like to apply the patch below to fix
>   this.
>
>   Is this OK ?

Looks like this problem was introduced by

2019-11-04  Kamlesh Kumar  

* cp-demangle.c (d_expr_primary): Handle
nullptr demangling.
* testsuite/demangle-expected: Added test.

https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00064.html

Kamlesh, Jason, can you confirm that Nick's change to the testsuite is
testing the expected demangling, and that the current entry in the
testsuite is incorrect?  Thanks.

Ian


> libiberty/ChangeLog
> 2020-01-20  Nick Clifton  
>
>   * testsuite/demangle-expected: Fix expected demangling.
>
> Index: libiberty/testsuite/demangle-expected
> ===
> --- libiberty/testsuite/demangle-expected (revision 280157)
> +++ libiberty/testsuite/demangle-expected (working copy)
> @@ -1449,4 +1449,4 @@
>  #PR91979 demangling nullptr expression
>  
>  _Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE
> -void foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))), void>::type*)
> +void foo<(void*)0>(enable_if<((void*)0)==(decltype(nullptr)), void>::type*)


Re: RFA: Fix libiberty testsuite failure

2020-01-20 Thread Ian Lance Taylor
kamlesh kumar  writes:

> yes, current expected entry is wrong and
> Nick's patch corrects that.

Thanks.  Nick, the patch is OK.

Ian

> On Mon, Jan 20, 2020 at 9:29 PM Ian Lance Taylor  wrote:
>
>> Nick Clifton  writes:
>>
>> > Hi Ian,
>> >
>> >   The libiberty testsuite in the gcc mainline is currently failing on
>> >   the last test:
>> >
>> > FAIL at line 1452, options :
>> > in:  _Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE
>> > out: void foo<(void*)0>(enable_if<((void*)0)==(decltype(nullptr)),
>> void>::type*)
>> > exp: void foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))),
>> void>::type*)
>> >
>> >   To me it looks like the expected demangling is incorrect - it wants a
>> >   double set of parentheses around decltype(nullptr) when I think that
>> >   only one is needed.  So I would like to apply the patch below to fix
>> >   this.
>> >
>> >   Is this OK ?
>>
>> Looks like this problem was introduced by
>>
>> 2019-11-04  Kamlesh Kumar  
>>
>> * cp-demangle.c (d_expr_primary): Handle
>> nullptr demangling.
>> * testsuite/demangle-expected: Added test.
>>
>> https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00064.html
>>
>> Kamlesh, Jason, can you confirm that Nick's change to the testsuite is
>> testing the expected demangling, and that the current entry in the
>> testsuite is incorrect?  Thanks.
>>
>> Ian
>>
>>
>> > libiberty/ChangeLog
>> > 2020-01-20  Nick Clifton  
>> >
>> >   * testsuite/demangle-expected: Fix expected demangling.
>> >
>> > Index: libiberty/testsuite/demangle-expected
>> > ===
>> > --- libiberty/testsuite/demangle-expected (revision 280157)
>> > +++ libiberty/testsuite/demangle-expected (working copy)
>> > @@ -1449,4 +1449,4 @@
>> >  #PR91979 demangling nullptr expression
>> >
>> >  _Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE
>> > -void foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))),
>> void>::type*)
>> > +void foo<(void*)0>(enable_if<((void*)0)==(decltype(nullptr)),
>> void>::type*)
>>


Re: [PATCH v3] Add `--with-toolexeclibdir=' configuration option

2020-01-20 Thread Ian Lance Taylor
On Mon, Jan 20, 2020 at 6:46 PM Maciej W. Rozycki  wrote:
>
>  Ian: Can we please coordinate this somehow?  The libgo/ part, like all,
> relies on config/toolexeclibdir.m4, so I can either:
>
> 1. push the whole change all at once and you'll push the libgo/ part to
>your repo independently, which shouldn't be an issue except perhaps for
>policy reasons as the changes will be identical anyway, or
>
> 2. push all the bits sans the libgo/ part and you'll push the libgo/ part
>to your repo and then you'll merge it to GCC.
>
> There is a slight technical advantage to going with #1 as there'll be no
> window where the new option is not consistently supported; it's also less
> work as you won't have to do the merge.  But I have no strong preference
> either way.

I'd rather do #2.  Thanks.  A small window is unlikely to matter to
anyone.  Let me know when the rest of the patch is committed.

Ian


libgo patch committed: Update to Go1.14beta1

2020-01-21 Thread Ian Lance Taylor
I've committed a patch to update libgo to Go 1.14beta1.  As usual with
these updates the patch is far too large to include in this e-mail
message.  I've included the diffs for gccgo-specific files.
Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
mainline.

Ian

gotools/ChangeLog:

2020-01-21  Ian Lance Taylor  

* Makefile.am (gofmt$(EXEEXT)): Link against $(LIBGOTOOL).
(check-go-tool): Copy some vendor directories.
* Makefile.in: Regenerate.
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a6127013783..dff5fb5bc70 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-a69ad9c7d1b45edcf8062a07d3a3c9b6838c04f8
+c2225a76d1e15f28056596807ebbbc526d4c58da
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 4b2dd58d40a..56d38f57e7d 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -262,7 +262,8 @@ toolexeclibgohash_DATA = \
hash/adler32.gox \
hash/crc32.gox \
hash/crc64.gox \
-   hash/fnv.gox
+   hash/fnv.gox \
+   hash/maphash.gox
 
 toolexeclibgohtmldir = $(toolexeclibgodir)/html
 
@@ -402,6 +403,7 @@ toolexeclibgounicode_DATA = \
 noinst_DATA = \
golang.org/x/net/nettest.gox \
internal/cfg.gox \
+   internal/obscuretestdata.gox \
internal/testenv.gox \
internal/trace.gox \
net/internal/socktest.gox \
diff --git a/libgo/configure.ac b/libgo/configure.ac
index d4ee59ca685..07c03bcdf26 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -10,7 +10,7 @@ AC_INIT(package-unused, version-unused,, libgo)
 AC_CONFIG_SRCDIR(Makefile.am)
 AC_CONFIG_HEADER(config.h)
 
-libtool_VERSION=15:0:0
+libtool_VERSION=16:0:0
 AC_SUBST(libtool_VERSION)
 
 AM_ENABLE_MULTILIB(, ..)
diff --git a/libgo/VERSION b/libgo/VERSION
index e0f726521a4..da5318592de 100644
--- a/libgo/VERSION
+++ b/libgo/VERSION
@@ -1 +1 @@
-go1.13
+go1.14beta1
diff --git a/libgo/check-packages.txt b/libgo/check-packages.txt
index 156a2bd4593..48c4dfdbc91 100644
--- a/libgo/check-packages.txt
+++ b/libgo/check-packages.txt
@@ -3,7 +3,6 @@ archive/zip
 bufio
 bytes
 cmd/go/internal/cache
-cmd/go/internal/dirhash
 cmd/go/internal/generate
 cmd/go/internal/get
 cmd/go/internal/imports
@@ -13,13 +12,10 @@ cmd/go/internal/lockedfile/internal/filelock
 cmd/go/internal/modconv
 cmd/go/internal/modfetch
 cmd/go/internal/modfetch/codehost
-cmd/go/internal/modfile
 cmd/go/internal/modload
-cmd/go/internal/module
 cmd/go/internal/mvs
 cmd/go/internal/par
 cmd/go/internal/search
-cmd/go/internal/semver
 cmd/go/internal/txtar
 cmd/go/internal/work
 cmd/internal/buildid
@@ -96,6 +92,7 @@ hash/adler32
 hash/crc32
 hash/crc64
 hash/fnv
+hash/maphash
 html
 html/template
 image
@@ -163,6 +160,8 @@ strings
 sync
 sync/atomic
 syscall
+testing
+testing/iotest
 testing/quick
 text/scanner
 text/tabwriter
diff --git a/libgo/gotool-packages.txt b/libgo/gotool-packages.txt
index b5a3bbda3b8..90521ae0b50 100644
--- a/libgo/gotool-packages.txt
+++ b/libgo/gotool-packages.txt
@@ -5,7 +5,6 @@ cmd/go/internal/cache
 cmd/go/internal/cfg
 cmd/go/internal/clean
 cmd/go/internal/cmdflag
-cmd/go/internal/dirhash
 cmd/go/internal/doc
 cmd/go/internal/envcmd
 cmd/go/internal/fix
@@ -22,23 +21,17 @@ cmd/go/internal/modcmd
 cmd/go/internal/modconv
 cmd/go/internal/modfetch
 cmd/go/internal/modfetch/codehost
-cmd/go/internal/modfile
 cmd/go/internal/modget
 cmd/go/internal/modinfo
 cmd/go/internal/modload
-cmd/go/internal/module
 cmd/go/internal/mvs
-cmd/go/internal/note
 cmd/go/internal/par
 cmd/go/internal/renameio
 cmd/go/internal/robustio
 cmd/go/internal/run
 cmd/go/internal/search
-cmd/go/internal/semver
 cmd/go/internal/str
-cmd/go/internal/sumweb
 cmd/go/internal/test
-cmd/go/internal/tlog
 cmd/go/internal/tool
 cmd/go/internal/txtar
 cmd/go/internal/version
@@ -47,10 +40,22 @@ cmd/go/internal/web
 cmd/go/internal/work
 cmd/internal/browser
 cmd/internal/buildid
+cmd/internal/diff
 cmd/internal/edit
 cmd/internal/objabi
 cmd/internal/sys
 cmd/internal/test2json
+golang.org/x/crypto/ed25519
+golang.org/x/crypto/ed25519/internal/edwards25519
+golang.org/x/mod/internal/lazyregexp
+golang.org/x/mod/modfile
+golang.org/x/mod/module
+golang.org/x/mod/semver
+golang.org/x/mod/sumdb
+golang.org/x/mod/sumdb/dirhash
+golang.org/x/mod/sumdb/note
+golang.org/x/mod/sumdb/tlog
+golang.org/x/mod/zip
 golang.org/x/tools/go/analysis
 golang.org/x/tools/go/analysis/internal/analysisflags
 golang.org/x/tools/go/analysis/internal/facts
@@ -86,3 +91,5 @@ golang.org/x/tools/go/ast/inspector
 golang.org/x/tools/go/cfg
 golang.org/x/tools/go/types/objectpath
 golang.org/x/tools/go/types/typeutil
+golang.org/x/xerrors
+golang.org/x/xerrors/internal
diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt
index b19747a05b9..2b5fba806c6 100644
--- a/libgo/libgo-packages.txt
+++ b/libgo/libgo-packages.txt
@@ -72,12 +7

libgo patch committed: Update runtime_nanotime call

2020-01-22 Thread Ian Lance Taylor
In the update of libgo to Go1.14beta1, the function runtime_nanotime
was renamed to runtime_nanotime1.  I missed one reference that is not
compiled on x86 code.  This patch fixes that.  This fixes
https://golang.org/issue/36694.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index dff5fb5bc70..61f01d739ff 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-c2225a76d1e15f28056596807ebbbc526d4c58da
+94a5ff53df24c58c5e6629ce6720a02aa9986322
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/runtime/runtime_c.c b/libgo/runtime/runtime_c.c
index e7951a051a6..18222c14465 100644
--- a/libgo/runtime/runtime_c.c
+++ b/libgo/runtime/runtime_c.c
@@ -97,7 +97,7 @@ runtime_cputicks(void)
   // Currently cputicks() is used in blocking profiler and to seed 
runtime·fastrand().
   // runtime·nanotime() is a poor approximation of CPU ticks that is enough 
for the profiler.
   // randomNumber provides better seeding of fastrand.
-  return runtime_nanotime() + randomNumber;
+  return runtime_nanotime1() + randomNumber;
 #endif
 }
 


libgo patch commited: Fix arm64be build

2020-01-22 Thread Ian Lance Taylor
This patch from Andrew Pinski fixes the libgo arm64be build, by using
internal/syscall/unix/getrandom_linux_generic.go on arm64be.
Committed to mainline.

Ian
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 61f01d739ff..544c6e66e0d 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-94a5ff53df24c58c5e6629ce6720a02aa9986322
+9ae2223f91c4ca642885b80d88eb0baf756acf94
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/internal/syscall/unix/getrandom_linux_generic.go 
b/libgo/go/internal/syscall/unix/getrandom_linux_generic.go
index 95748d5ebad..0c79ae54f4b 100644
--- a/libgo/go/internal/syscall/unix/getrandom_linux_generic.go
+++ b/libgo/go/internal/syscall/unix/getrandom_linux_generic.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build linux
-// +build arm64 nios2 riscv64
+// +build arm64 arm64be nios2 riscv64
 
 package unix
 


libgo patch committed: Fix Solaris build

2020-01-22 Thread Ian Lance Taylor
This libgo patch fixes the build on Solaris after the 1.14beta
upgrade.  It adds a runtime.osinit function, and drops a duplicate
runtime.getncpu function.  Bootstrapped and tested on
x86_64-pc-solaris2.11.  Committed to mainline.

Ian
9e16359ce8db7180264fd5f047ca137ead8356dd
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 544c6e66e0d..a778a8540a5 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-9ae2223f91c4ca642885b80d88eb0baf756acf94
+1d64b76f559c0969ee2a6eb8e0ac9d268713880c
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/os3_solaris.go b/libgo/go/runtime/os3_solaris.go
index 001feed3e06..b2fa1d35f0e 100644
--- a/libgo/go/runtime/os3_solaris.go
+++ b/libgo/go/runtime/os3_solaris.go
@@ -17,12 +17,11 @@ func getPageSize() int32
 //extern sysconf
 func sysconf(int32) _C_long
 
-func getncpu() int32 {
-   n := int32(sysconf(__SC_NPROCESSORS_ONLN))
-   if n < 1 {
-   return 1
+func osinit() {
+   ncpu = getncpu()
+   if physPageSize == 0 {
+   physPageSize = uintptr(getPageSize())
}
-   return n
 }
 
 func sysargs(argc int32, argv **byte) {


Re: libgo patch committed: Update to Go1.14beta1

2020-01-22 Thread Ian Lance Taylor
On Wed, Jan 22, 2020 at 12:18 PM Rainer Orth
 wrote:
>
> > I've committed a patch to update libgo to Go 1.14beta1.  As usual with
> > these updates the patch is far too large to include in this e-mail
> > message.  I've included the diffs for gccgo-specific files.
> > Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
> > mainline.
>
> the patch broke Solaris bootstrap:
>
> /vol/gcc/src/hg/master/local/libgo/go/runtime/os_only_solaris.go:11:1: error: 
> redefinition of 'getncpu'
>11 | func getncpu() int32 {
>   | ^
> /vol/gcc/src/hg/master/local/libgo/go/runtime/os3_solaris.go:20:1: note: 
> previous definition of 'getncpu' was here
>20 | func getncpu() int32 {
>   | ^
>
> There are 3 definitions in the Solaris/Illumos space:
>
> * os_only_solaris.go is guarded by !illumos
>
> * os3_solaris.go has no explicit guard
>
> * illumos hat its own one in os_illumos.go
>
> so the os3_solaris.go one can go.
>
> /vol/gcc/src/hg/master/local/libgo/go/runtime/stubs2.go:40:3: error: osinit 
> is not defined
>40 | //go:linkname osinit runtime.osinit
>   |   ^
>
> Upstream has a definition in os3_solaris.go.
>
> The following patch allows compilation to succeed.

Thanks, I already committed a patch before I got to your e-mail.
Sorry for the duplicate work.

Ian


Merge from trunk to gccgo branch

2020-01-22 Thread Ian Lance Taylor
I merged trunk revision 9e16359ce8db7180264fd5f047ca137ead8356dd to
the gccgo branch.

Ian


libgo patch committed: Skip type descriptors in testsuite script

2020-01-22 Thread Ian Lance Taylor
This libgo patch changes the testsuite script to explicitly skip type
descriptors.  Type descriptors are normally weak and GNU nm will
report them as V, so we will skip them when collecting the list of
symbols.  But when not using GNU nm, they may be reported as D, so
also skip them in symstogo.  This fixes go/doc/check on Solaris.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
927dd4e83a80e250b74e49cf348d3d42c7dd0a90
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a778a8540a5..a8ba3afe86e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-1d64b76f559c0969ee2a6eb8e0ac9d268713880c
+7d3081ce69dda123d77e35e8b9d282e40e9465e2
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index de4a392b8cd..33f99d77a31 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -517,6 +517,11 @@ symtogo() {
 if expr "$tp" : '^\.' >/dev/null 2>&1; then
   continue
 fi
+# Skip type descriptors.  These are normally skipped because they
+# are weak symbols, but if not using GNU nm we may see them here.
+if expr "$tp" : '^type\.\.' >/dev/null 2>&1; then
+  continue
+fi
 s=$(echo "$tp" | sed -e 's/\.\.z2f/%/g' | sed -e 's/.*%//')
 # Screen out methods (X.Y.Z).
 if ! expr "$s" : '^[^.]*\.[^.]*$' >/dev/null 2>&1; then


Re: libgo patch committed: Update to Go1.14beta1

2020-01-23 Thread Ian Lance Taylor
On Thu, Jan 23, 2020 at 11:32 AM Maciej W. Rozycki  wrote:
>
> On Tue, 21 Jan 2020, Ian Lance Taylor wrote:
>
> > I've committed a patch to update libgo to Go 1.14beta1.  As usual with
> > these updates the patch is far too large to include in this e-mail
> > message.  I've included the diffs for gccgo-specific files.
>
>  It seems to have broken the `riscv64-linux-gnu' target:
>
> cpugen.go:2:7: error: redefinition of 'CacheLinePadSize'
> 2 | const CacheLinePadSize = 64
>   |   ^
> .../libgo/go/internal/cpu/cpu_riscv64.go:7:7: note: previous definition of 
> 'CacheLinePadSize' was here
> 7 | const CacheLinePadSize = 32
>   |   ^
> make[4]: *** [Makefile:2830: internal/cpu.lo] Error 1
> make[4]: Leaving directory '.../riscv64-linux-gnu/libgo'

Thanks.  Fixed like so.  Committed to mainline.

Ian
b83c78fe8fd12ce6c14fe2ca234edbbdac22cd79
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a8ba3afe86e..fc1dbaca8b9 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-7d3081ce69dda123d77e35e8b9d282e40e9465e2
+10a8dbfc9945c672d59af8edb9790e2019cdeb27
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/internal/cpu/cpu_riscv64.go 
b/libgo/go/internal/cpu/cpu_riscv64.go
index c49cab79fdc..d920fcf7a6d 100644
--- a/libgo/go/internal/cpu/cpu_riscv64.go
+++ b/libgo/go/internal/cpu/cpu_riscv64.go
@@ -3,5 +3,3 @@
 // license that can be found in the LICENSE file.
 
 package cpu
-
-const CacheLinePadSize = 32


Re: [committed v4] Add `--with-toolexeclibdir=' configuration option

2020-01-24 Thread Ian Lance Taylor
On Fri, Jan 24, 2020 at 3:27 AM Maciej W. Rozycki  wrote:
>
> Provide means, in the form of a `--with-toolexeclibdir=' configuration
> option, to override the default installation directory for target
> libraries, otherwise known as $toolexeclibdir.  This is so that it is
> possible to get newly-built libraries, particularly the shared ones,
> installed in a common place, so that they can be readily used by the
> target system as their host libraries, possibly over NFS, without a need
> to manually copy them over from the currently hardcoded location they
> would otherwise be installed in.
>
> In the presence of the `--enable-version-specific-runtime-libs' option
> and for configurations building native GCC the option is ignored.
>
> ---
> On Mon, 20 Jan 2020, Ian Lance Taylor wrote:
>
> > > 2. push all the bits sans the libgo/ part and you'll push the libgo/ part
> > >to your repo and then you'll merge it to GCC.
> > >
> > > There is a slight technical advantage to going with #1 as there'll be no
> > > window where the new option is not consistently supported; it's also less
> > > work as you won't have to do the merge.  But I have no strong preference
> > > either way.
> >
> > I'd rather do #2.  Thanks.  A small window is unlikely to matter to
> > anyone.  Let me know when the rest of the patch is committed.
>
>  This is the version I have committed.  I've also attached the libgo part
> with a ChangeLog entry for your convenience (you'll have to write your own
> change description though).


Thanks.  Committed upstream and to GCC master.

Ian


Go patch committed: Cleanups for MPFR 3.1.0

2020-01-27 Thread Ian Lance Taylor
This patch to the Go frontend adds cleanups now that MPFR 3.1.0 is
required.  For MPFR functions, change from GMP_RND* to MPFR_RND*.
Also change mp_exp_t to mpfr_expt_t.  This fixes GCC PR 92463.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu (with MPFR
4.0.2).  Committed to mainline.

Ian
b1321526a1de86d4feadef1bc9b1a64f45ceebb8
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 38872c44eab..49312fa10f7 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-197381c6364431a7a05e32df683874b7cadcc4b4
+132e0e61d59aaa52f8fdb03a925300c1ced2a0f2
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 14bec9a427f..42ad93b9830 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -2580,11 +2580,11 @@ Integer_expression::do_import(Import_expression* imp, 
Location loc)
  return Expression::make_error(loc);
}
   if (pos == std::string::npos)
-   mpfr_set_ui(real, 0, GMP_RNDN);
+   mpfr_set_ui(real, 0, MPFR_RNDN);
   else
{
  std::string real_str = num.substr(0, pos);
- if (mpfr_init_set_str(real, real_str.c_str(), 10, GMP_RNDN) != 0)
+ if (mpfr_init_set_str(real, real_str.c_str(), 10, MPFR_RNDN) != 0)
{
  go_error_at(imp->location(), "bad number in import data: %qs",
  real_str.c_str());
@@ -2599,7 +2599,7 @@ Integer_expression::do_import(Import_expression* imp, 
Location loc)
imag_str = num.substr(pos);
   imag_str = imag_str.substr(0, imag_str.size() - 1);
   mpfr_t imag;
-  if (mpfr_init_set_str(imag, imag_str.c_str(), 10, GMP_RNDN) != 0)
+  if (mpfr_init_set_str(imag, imag_str.c_str(), 10, MPFR_RNDN) != 0)
{
  go_error_at(imp->location(), "bad number in import data: %qs",
  imag_str.c_str());
@@ -2639,7 +2639,7 @@ Integer_expression::do_import(Import_expression* imp, 
Location loc)
   else
 {
   mpfr_t val;
-  if (mpfr_init_set_str(val, num.c_str(), 10, GMP_RNDN) != 0)
+  if (mpfr_init_set_str(val, num.c_str(), 10, MPFR_RNDN) != 0)
{
  go_error_at(imp->location(), "bad number in import data: %qs",
  num.c_str());
@@ -2753,7 +2753,7 @@ class Float_expression : public Expression
 : Expression(EXPRESSION_FLOAT, location),
   type_(type)
   {
-mpfr_init_set(this->val_, *val, GMP_RNDN);
+mpfr_init_set(this->val_, *val, MPFR_RNDN);
   }
 
   // Write VAL to export data.
@@ -2923,8 +2923,8 @@ Float_expression::do_get_backend(Translate_context* 
context)
 void
 Float_expression::export_float(String_dump *exp, const mpfr_t val)
 {
-  mp_exp_t exponent;
-  char* s = mpfr_get_str(NULL, &exponent, 10, 0, val, GMP_RNDN);
+  mpfr_exp_t exponent;
+  char* s = mpfr_get_str(NULL, &exponent, 10, 0, val, MPFR_RNDN);
   if (*s == '-')
 exp->write_c_string("-");
   exp->write_c_string("0.");
@@ -4781,7 +4781,7 @@ Unary_expression::eval_constant(Operator op, const 
Numeric_constant* unc,
  unc->get_float(&uval);
  mpfr_t val;
  mpfr_init(val);
- mpfr_neg(val, uval, GMP_RNDN);
+ mpfr_neg(val, uval, MPFR_RNDN);
  nc->set_float(unc->type(), val);
  mpfr_clear(uval);
  mpfr_clear(val);
@@ -5613,8 +5613,8 @@ Binary_expression::compare_float(const Numeric_constant* 
left_nc,
   if (!type->is_abstract() && type->float_type() != NULL)
 {
   int bits = type->float_type()->bits();
-  mpfr_prec_round(left_val, bits, GMP_RNDN);
-  mpfr_prec_round(right_val, bits, GMP_RNDN);
+  mpfr_prec_round(left_val, bits, MPFR_RNDN);
+  mpfr_prec_round(right_val, bits, MPFR_RNDN);
 }
 
   *cmp = mpfr_cmp(left_val, right_val);
@@ -5649,10 +5649,10 @@ Binary_expression::compare_complex(const 
Numeric_constant* left_nc,
   if (!type->is_abstract() && type->complex_type() != NULL)
 {
   int bits = type->complex_type()->bits();
-  mpfr_prec_round(mpc_realref(left_val), bits / 2, GMP_RNDN);
-  mpfr_prec_round(mpc_imagref(left_val), bits / 2, GMP_RNDN);
-  mpfr_prec_round(mpc_realref(right_val), bits / 2, GMP_RNDN);
-  mpfr_prec_round(mpc_imagref(right_val), bits / 2, GMP_RNDN);
+  mpfr_prec_round(mpc_realref(left_val), bits / 2, MPFR_RNDN);
+  mpfr_prec_round(mpc_imagref(left_val), bits / 2, MPFR_RNDN);
+  mpfr_prec_round(mpc_realref(right_val), bits / 2, MPFR_RNDN);
+  mpfr_prec_round(mpc_imagref(right_val), bits / 2, MPFR_RNDN);
 }
 
   *cmp = mpc_cmp(left_val, right_val) != 0;
@@ -5899,10 +5899,10 @@ Binary_expression::eval_float(Operator op, const 
Numeric_constant* left_nc,
   switch (op)
 {
 case OPERATOR_PLUS:
-  mpfr_add(val, left_val, right_val, GMP_RNDN);
+  mpfr_add(val, left_val, right_val, MPFR_RNDN);
   break;
 case OPER

libgo patch committed: Update netpoll_hurd for Go 1.14beta1 changes

2020-01-29 Thread Ian Lance Taylor
This patch by Svante Signell updates runtime/netpoll_hurd.go for the
changes in the Go 1.14beta1 release.  Bootstrapped on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
58d788fafbc4cc8cc25ca432e8127e1effdc0672
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 49312fa10f7..8d08e91211d 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-132e0e61d59aaa52f8fdb03a925300c1ced2a0f2
+5b438257e6fe5f344ae2f973313f394cda85bf62
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/netpoll_hurd.go b/libgo/go/runtime/netpoll_hurd.go
index b74ad2fe128..3d3fa4b76d3 100644
--- a/libgo/go/runtime/netpoll_hurd.go
+++ b/libgo/go/runtime/netpoll_hurd.go
@@ -85,6 +85,10 @@ func netpolldescriptor() uintptr {
return uintptr(rdwake<<16 | wrwake)
 }
 
+func netpollIsPollDescriptor(fd uintptr) bool {
+   return fd == uintptr(rdwake) || fd == uintptr(wrwake)
+}
+
 // netpollwakeup writes on wrwake to wakeup poll before any changes.
 func netpollwakeup() {
if pendingUpdates == 0 {
@@ -158,17 +162,32 @@ func netpollarm(pd *pollDesc, mode int) {
unlock(&mtxset)
 }
 
-// polls for ready network connections
-// returns list of goroutines that become runnable
+// netpollBreak interrupts an epollwait.
+func netpollBreak() {
+   netpollwakeup()
+}
+
+// netpoll checks for ready network connections.
+// Returns list of goroutines that become runnable.
+// delay < 0: blocks indefinitely
+// delay == 0: does not block, just polls
+// delay > 0: block for up to that many nanoseconds
 //go:nowritebarrierrec
-func netpoll(block bool) gList {
+func netpoll(delay int64) gList {
timeout := int32(0)
-   if !block {
+   if delay < 0 {
timeout = 0
+   } else if delay == 0 {
+   // TODO: call poll with timeout == 0
return gList{}
-   }
-   if pollVerbose {
-   println("*** netpoll", block)
+   } else if delay < 1e6 {
+   timeout = 1
+   } else if delay < 1e15 {
+   timeout = int32(delay / 1e6)
+   } else {
+   // An arbitrary cap on how long to wait for a timer.
+   // 1e9 ms == ~11.5 days.
+   timeout = 1e9
}
 retry:
lock(&mtxpoll)
@@ -176,40 +195,37 @@ retry:
pendingUpdates = 0
unlock(&mtxpoll)
 
-   if pollVerbose {
-   println("*** netpoll before poll")
-   }
n := libc_poll(&pfds[0], int32(len(pfds)), timeout)
-   if pollVerbose {
-   println("*** netpoll after poll", n)
-   }
if n < 0 {
e := errno()
if e != _EINTR {
println("errno=", e, " len(pfds)=", len(pfds))
throw("poll failed")
}
-   if pollVerbose {
-   println("*** poll failed")
-   }
unlock(&mtxset)
+   // If a timed sleep was interrupted, just return to
+   // recalculate how long we should sleep now.
+   if timeout > 0 {
+   return gList{}
+   }
goto retry
}
// Check if some descriptors need to be changed
if n != 0 && pfds[0].revents&(_POLLIN|_POLLHUP|_POLLERR) != 0 {
-   var b [1]byte
-   for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 {
-   if pollVerbose {
-   println("*** read 1 byte from pipe")
+   if delay != 0 {
+   // A netpollwakeup could be picked up by a
+   // non-blocking poll. Only clear the wakeup
+   // if blocking.
+   var b [1]byte
+   for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 {
}
}
-   // Do not look at the other fds in this case as the mode may 
have changed
-   // XXX only additions of flags are made, so maybe it is ok
-   unlock(&mtxset)
-   goto retry
+   // Still look at the other fds even if the mode may have
+   // changed, as netpollBreak might have been called.
+   n--
}
var toRun gList
-   for i := 0; i < len(pfds) && n > 0; i++ {
+   for i := 1; i < len(pfds) && n > 0; i++ {
pfd := &pfds[i]
 
var mode int32
@@ -222,19 +238,14 @@ retry:
pfd.events &= ^_POLLOUT
}
if mode != 0 {
-   if pollVerbose {
-   println("*** netpollready i=", i, "revents=", 
pfd.revents, "events=", pfd.events, "pd=", pds[i])
+   pds[i].everr = false
+   if pfd.revents == _POLLERR {
+   

libgo patch committed: Add a couple of hurd build tags

2020-01-29 Thread Ian Lance Taylor
This libgo patch by Svante Signell adds a couple of hurd build to the
runtime and syscall packages.  Bootstrapped on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
66af5a226acd0edfbafcbcac76ed268cee0612ed
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 8d08e91211d..40529518b26 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-5b438257e6fe5f344ae2f973313f394cda85bf62
+d796680b5a78f686ed118578e81d5b1adf48508d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/nbpipe_pipe2.go b/libgo/go/runtime/nbpipe_pipe2.go
index e3639d99b15..76fb40c460a 100644
--- a/libgo/go/runtime/nbpipe_pipe2.go
+++ b/libgo/go/runtime/nbpipe_pipe2.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build freebsd linux netbsd openbsd solaris
+// +build freebsd hurd linux netbsd openbsd solaris
 
 package runtime
 
diff --git a/libgo/go/syscall/sockcmsg_unix_other.go 
b/libgo/go/syscall/sockcmsg_unix_other.go
index 65d9f187c4e..3e7afe4a4ac 100644
--- a/libgo/go/syscall/sockcmsg_unix_other.go
+++ b/libgo/go/syscall/sockcmsg_unix_other.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin freebsd linux netbsd openbsd solaris
+// +build aix darwin freebsd hurd linux netbsd openbsd solaris
 
 package syscall
 


libbacktrace patch committed: Always build tests with -g

2020-02-03 Thread Ian Lance Taylor
This patch ensures that the libbacktrace tests are always built with
-g.  It also builds them with the default warning flags, so I had to
add a few casts to ztest.c to get it pass without warnings.  This
should fix PR 90636.  Bootstrapped and ran libbacktrace tests on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

2020-02-03  Ian Lance Taylor  

* Makefile.am (libbacktrace_TEST_CFLAGS): Define.
(test_elf32_CFLAGS): Use $(libbacktrace_test_CFLAGS).
(test_elf_64_CFLAGS, test_xcoff_32_CFLAGS): Likewise.
(test_xcoff_64_CFLAGS, test_pecoff_CFLAGS): Likewise.
(test_unknown_CFLAGS, unittest_CFLAGS): Likewise.
(unittest_alloc_CFLAGS, allocfail_CFLAGS): Likewise.
(b2test_CFLAGS, b3test_CFLAGS, btest_CFLAGS): Likewise.
(btest_lto_CFLAGS, btest_alloc_CFLAGS, stest_CFLAGS): Likewise.
(stest_alloc_CFLAGS): Likewise.
* Makefile.in: Regenerate.
* ztest.c (error_callback_compress): Mark vdata unused.
(test_large): Add casts to avoid warnings.
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index b251b7bc34a..c73f6633a76 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -93,6 +93,9 @@ TESTS =
 # Add test to this variable, if you want it to be build and run.
 BUILDTESTS =
 
+# Flags to use when compiling test programs.
+libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
+
 if NATIVE
 check_LTLIBRARIES = libbacktrace_alloc.la
 
@@ -149,41 +152,49 @@ xcoff_%.c: xcoff.c
mv $@.tmp $@
 
 test_elf_32_SOURCES = test_format.c testlib.c
+test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
 
 BUILDTESTS += test_elf_32
 
 test_elf_64_SOURCES = test_format.c testlib.c
+test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
 
 BUILDTESTS += test_elf_64
 
 test_xcoff_32_SOURCES = test_format.c testlib.c
+test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
 
 BUILDTESTS += test_xcoff_32
 
 test_xcoff_64_SOURCES = test_format.c testlib.c
+test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
 
 BUILDTESTS += test_xcoff_64
 
 test_pecoff_SOURCES = test_format.c testlib.c
+test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
 
 BUILDTESTS += test_pecoff
 
 test_unknown_SOURCES = test_format.c testlib.c
+test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
 
 BUILDTESTS += test_unknown
 
 unittest_SOURCES = unittest.c testlib.c
+unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 unittest_LDADD = libbacktrace.la
 
 BUILDTESTS += unittest
 
 unittest_alloc_SOURCES = $(unittest_SOURCES)
+unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 unittest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += unittest_alloc
@@ -200,6 +211,7 @@ libbacktrace_instrumented_alloc_la_DEPENDENCIES = \
 instrumented_alloc.lo: alloc.c
 
 allocfail_SOURCES = allocfail.c testlib.c
+allocfail_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 allocfail_LDADD = libbacktrace_instrumented_alloc.la
 
 check_PROGRAMS += allocfail
@@ -212,7 +224,7 @@ if HAVE_ELF
 if HAVE_OBJCOPY_DEBUGLINK
 
 b2test_SOURCES = $(btest_SOURCES)
-b2test_CFLAGS = $(btest_CFLAGS)
+b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 b2test_LDFLAGS = -Wl,--build-id
 b2test_LDADD = libbacktrace_elf_for_test.la
 
@@ -222,7 +234,7 @@ TESTS += b2test_buildid
 if HAVE_DWZ
 
 b3test_SOURCES = $(btest_SOURCES)
-b3test_CFLAGS = $(btest_CFLAGS)
+b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 b3test_LDFLAGS = -Wl,--build-id
 b3test_LDADD = libbacktrace_elf_for_test.la
 
@@ -235,7 +247,7 @@ endif HAVE_OBJCOPY_DEBUGLINK
 endif HAVE_ELF
 
 btest_SOURCES = btest.c testlib.c
-btest_CFLAGS = $(AM_CFLAGS) -g -O
+btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
 btest_LDADD = libbacktrace.la
 
 BUILDTESTS += btest
@@ -243,7 +255,7 @@ BUILDTESTS += btest
 if HAVE_ELF
 
 btest_lto_SOURCES = btest.c testlib.c
-btest_lto_CFLAGS = $(AM_CFLAGS) -g -O -flto
+btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto
 btest_lto_LDADD = libbacktrace.la
 
 BUILDTESTS += btest_lto
@@ -251,7 +263,7 @@ BUILDTESTS += btest_lto
 endif HAVE_ELF
 
 btest_alloc_SOURCES = $(btest_SOURCES)
-btest_alloc_CFLAGS = $(btest_CFLAGS)
+btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 btest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += btest_alloc
@@ -277,11 +289,13 @@ endif HAVE_OBJCOPY_DEBUGLINK
 endif HAVE_DWZ
 
 stest_SOURCES = stest.c
+stest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 stest_LDADD = libbacktrace.la
 
 BUILDTESTS += stest
 
 stest_alloc_SOURCES = $(stest_SOURCES)
+stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 stest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += stest_alloc
@@ -289,7 +303,7 @@ BUILDTESTS += stest_alloc
 if HAVE_ELF
 
 ztest_SOURCES = ztest.c testlib.c
-ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
+ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS

Re: libgo patch committed: Update to Go1.14beta1

2020-02-03 Thread Ian Lance Taylor
On Sat, Feb 1, 2020 at 5:38 AM Andreas Schwab  wrote:
>
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:7:14: error: imported and 
> not used: unsafe
> 7 | import "unsafe"
>   |  ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:13:1: error: redefinition 
> of 'SetLen'
>13 | func (iov *Iovec) SetLen(length int) {
>   | ^
> ../../../libgo/go/syscall/socket.go:437:1: note: previous definition of 
> 'SetLen' was here
>   437 | func (iov *Iovec) SetLen(length int) {
>   | ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:17:1: error: redefinition 
> of 'SetControllen'
>17 | func (msghdr *Msghdr) SetControllen(length int) {
>   | ^
> ../../../libgo/go/syscall/socket.go:441:1: note: previous definition of 
> 'SetControllen' was here
>   441 | func (msghdr *Msghdr) SetControllen(length int) {
>   | ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:21:1: error: redefinition 
> of 'SetLen'
>21 | func (cmsg *Cmsghdr) SetLen(length int) {
>   | ^
> ../../../libgo/go/syscall/socket.go:445:1: note: previous definition of 
> 'SetLen' was here
>   445 | func (cmsg *Cmsghdr) SetLen(length int) {
>   | ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:14:10: error: incompatible 
> types in assignment (cannot use type uint64 as type Iovec_len_t)
>14 |  iov.Len = uint64(length)
>   |  ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:18:20: error: incompatible 
> types in assignment (cannot use type uint64 as type Msghdr_controllen_t)
>18 |  msghdr.Controllen = uint64(length)
>   |^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:22:11: error: incompatible 
> types in assignment (cannot use type uint64 as type Cmsghdr_len_t)
>22 |  cmsg.Len = uint64(length)
>   |   ^


Thanks.  Fixed like so.  Committed to mainline.

Ian
79530f94e9c53153c4fae3b50a8c938f89db0c32
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 40529518b26..27f4ce342e5 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d796680b5a78f686ed118578e81d5b1adf48508d
+c94637ad6fd38d4814fb02d094a1a73f19323d71
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/syscall/syscall_linux_riscv64.go 
b/libgo/go/syscall/syscall_linux_riscv64.go
index e9aab94e3a1..16d8709708d 100644
--- a/libgo/go/syscall/syscall_linux_riscv64.go
+++ b/libgo/go/syscall/syscall_linux_riscv64.go
@@ -4,20 +4,6 @@
 
 package syscall
 
-import "unsafe"
-
 func (r *PtraceRegs) PC() uint64 { return r.Pc }
 
 func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
-
-func (iov *Iovec) SetLen(length int) {
-   iov.Len = uint64(length)
-}
-
-func (msghdr *Msghdr) SetControllen(length int) {
-   msghdr.Controllen = uint64(length)
-}
-
-func (cmsg *Cmsghdr) SetLen(length int) {
-   cmsg.Len = uint64(length)
-}


Re: libgo patch committed: Update to Go1.14beta1

2020-02-03 Thread Ian Lance Taylor
On Sun, Feb 2, 2020 at 2:27 AM Andreas Schwab  wrote:
>
> I'm getting these errors on aarch64 with -mabi=ilp32:
>
> ../../../../libgo/go/runtime/mpagealloc.go:226:38: error: shift count overflow
>   226 |  chunks [1 << pallocChunksL1Bits]*[1 << pallocChunksL2Bits]pallocData
>   |  ^
> ../../../../libgo/go/runtime/mgcscavenge.go:487:15: error: shift count 
> overflow
>   487 |l2 := (*[1 << 
> pallocChunksL2Bits]pallocData)(atomic.Loadp(unsafe.Pointer(&s.chunks[i.l1()])))
>   |   ^
> ../../../../libgo/go/runtime/mpagealloc.go:138:22: error: shift count overflow
>   138 |   return uint(i) & (1<   |  ^
> ../../../../libgo/go/runtime/mpagealloc.go:129:21: error: integer constant 
> overflow
>   129 |   return uint(i) >> pallocChunksL1Shift
>   | ^
> ../../../../libgo/go/runtime/mpagealloc_64bit.go:34:2: error: integer 
> constant overflow
>34 |  summaryL0Bits,
>   |  ^

I'm not sure that gccgo ever fully worked with aarch64 -mabi=ilp32.
In Go I think that will have to be represented with a new GOARCH
value, arm64p32.

Ian


libgo patch committed: On 32-bit systems, limit default GOMAXPROCS to 32

2020-02-15 Thread Ian Lance Taylor
This libgo patch limits the default value of GOMAXPROCS to 32 on
32-bit systems.  Otherwise we can easily run out of stack space for
threads.  The user can still override by setting GOMAXPROCS.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
a339c239a7ed8af25eb612ea4ceb5d975528b951
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 27f4ce342e5..9916b02c57f 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-c94637ad6fd38d4814fb02d094a1a73f19323d71
+3e46519cee5c916a9b39480fbac13f4ffc6a93b0
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go
index c0e85773098..e3f934ae7bd 100644
--- a/libgo/go/runtime/proc.go
+++ b/libgo/go/runtime/proc.go
@@ -563,6 +563,14 @@ func schedinit() {
 
sched.lastpoll = uint64(nanotime())
procs := ncpu
+
+   // In 32-bit mode, we can burn a lot of memory on thread stacks.
+   // Try to avoid this by limiting the number of threads we run
+   // by default.
+   if sys.PtrSize == 4 && procs > 32 {
+   procs = 32
+   }
+
if n, ok := atoi32(gogetenv("GOMAXPROCS")); ok && n > 0 {
procs = n
}


libgo patch committed: Update to 1.14rc1

2020-02-15 Thread Ian Lance Taylor
I've committed a patch to update libgo to the 1.14rc1 release (this is
a release candidate for the 1.14 Go release).  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian


patch.txt.bz2
Description: application/bzip


libbacktrace patch committed: Update test file

2020-02-15 Thread Ian Lance Taylor
This libbacktrace patch updates the test file used for comparisons
with zlib.  The file that the test was previously using, from libgo,
no longer exists.  Use its replacement file instead.  Bootstrapped and
ran libbacktrace tests on x86_64-pc-linux-gnu.  Committed to mainline.

Ian

2020-02-15  Ian Lance Taylor  

* ztest.c (test_large): Update file to current libgo test file.
diff --git a/libbacktrace/ztest.c b/libbacktrace/ztest.c
index 40f9c389a2a..2663c90061a 100644
--- a/libbacktrace/ztest.c
+++ b/libbacktrace/ztest.c
@@ -315,8 +315,8 @@ test_large (struct backtrace_state *state)
   size_t ctimes[16];
   size_t ztimes[16];
   static const char * const names[] = {
-"Mark.Twain-Tom.Sawyer.txt",
-"../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt"
+"Isaac.Newton-Opticks.txt",
+"../libgo/go/testdata/Isaac.Newton-Opticks.txt",
   };
 
   orig_buf = NULL;


libgo patch committed: Install internal/reflectlite.gox

2020-02-16 Thread Ian Lance Taylor
This patch to libgo arranges to install internal/reflectlite.gox.
This makes it possible to use gccgo to bootstrap Go 1.14.  If we don't
install this, gccgo can't compile the sort package, which expects to
be able to import this internal package.  This fixes GCC PR go/93679.
Bootstrapped on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
72700543b67561ab6a466e93b4c0d4fa8e6530e6
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index e67d792a44c..47dd5fbb908 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-f368afbbd466941dcc6717412d7182e122b40c93
+8505defaa91ecc5b42afd02eb335981e8b02b288
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 56d38f57e7d..dea09de592b 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -397,6 +397,11 @@ toolexeclibgounicode_DATA = \
unicode/utf16.gox \
unicode/utf8.gox
 
+# Some internal packages are needed to bootstrap the gc toolchain.
+toolexeclibgointernaldir = $(toolexeclibgodir)/internal
+toolexeclibgointernal_DATA = \
+   internal/reflectlite.gox
+
 # Some packages are only needed for tests, so unlike the other
 # internal packages nothing will explicitly depend on them.
 # Force them to be built.


libbacktrace patch committed: Simplify DWARF section handling

2019-12-04 Thread Ian Lance Taylor
This libbacktrace patch simplifies the DWARF section handling.  This
is in preparation for DWARF 5 support, as DWARF 5 requires us to read
more sections.  Bootstrapped and ran libbacktrace and Go tests on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

2019-12-04  Ian Lance Taylor  

* internal.h (enum dwarf_section): Define.
(struct dwarf_sections): Define.
(backtrace_dwarf_add): Update declaration to replace specific
section parameters with dwarf_sections parameter.
* dwarf.c (struct dwarf_data): Replace specific section fields
with dwarf_sections field.
(read_attribute): Use dwarf_sections with altlink.
(build_address_map): Replace specific section parameters with
dwarf_sections parameter.  Change all callers.
(read_line_info): Use dwarf_sections with ddata.
(read_referenced_name): Likewise.
(add_function_ranges): Likewise.
(read_function_entry): Likewise.
(read_function_info): Likewise.
(build_dwarf_data): Replace specific section parameters with
dwarf_sections parameter.  Change all callers.
(backtrace_dwarf_add): Likewise.
* elf.c (enum debug_section): Remove.
(dwarf_section_names): Remove .zdebug names.
(elf_add): Track zsections separately.  Build dwarf_sections.
* pecoff.c (enum debug_section): Remove.
(struct debug_section_info): Remove data field.
(coff_add): Build dwarf_sections.
* xcoff.c (enum dwarf_section): Remove.  Replace DWSECT_xxx
references with DEBUG_xxx references.
(xcoff_add): Build dwarf_sections.
Index: dwarf.c
===
--- dwarf.c (revision 278944)
+++ dwarf.c (working copy)
@@ -373,18 +373,8 @@ struct dwarf_data
   struct unit **units;
   /* Number of units in the list.  */
   size_t units_count;
-  /* The unparsed .debug_info section.  */
-  const unsigned char *dwarf_info;
-  size_t dwarf_info_size;
-  /* The unparsed .debug_line section.  */
-  const unsigned char *dwarf_line;
-  size_t dwarf_line_size;
-  /* The unparsed .debug_ranges section.  */
-  const unsigned char *dwarf_ranges;
-  size_t dwarf_ranges_size;
-  /* The unparsed .debug_str section.  */
-  const unsigned char *dwarf_str;
-  size_t dwarf_str_size;
+  /* The unparsed DWARF debug data.  */
+  struct dwarf_sections dwarf_sections;
   /* Whether the data is big-endian or not.  */
   int is_bigendian;
   /* A vector used for function addresses.  We keep this here so that
@@ -871,13 +861,14 @@ read_attribute (enum dwarf_form form, st
val->encoding = ATTR_VAL_NONE;
return 1;
  }
-   if (offset >= altlink->dwarf_str_size)
+   if (offset >= altlink->dwarf_sections.size[DEBUG_STR])
  {
dwarf_buf_error (buf, "DW_FORM_GNU_strp_alt out of range");
return 0;
  }
val->encoding = ATTR_VAL_STRING;
-   val->u.string = (const char *) altlink->dwarf_str + offset;
+   val->u.string =
+ (const char *) altlink->dwarf_sections.data[DEBUG_STR] + offset;
return 1;
   }
 default:
@@ -1499,10 +1490,7 @@ find_address_ranges (struct backtrace_st
 
 static int
 build_address_map (struct backtrace_state *state, uintptr_t base_address,
-  const unsigned char *dwarf_info, size_t dwarf_info_size,
-  const unsigned char *dwarf_abbrev, size_t dwarf_abbrev_size,
-  const unsigned char *dwarf_ranges, size_t dwarf_ranges_size,
-  const unsigned char *dwarf_str, size_t dwarf_str_size,
+  const struct dwarf_sections *dwarf_sections,
   int is_bigendian, struct dwarf_data *altlink,
   backtrace_error_callback error_callback, void *data,
   struct unit_addrs_vector *addrs,
@@ -1525,9 +1513,9 @@ build_address_map (struct backtrace_stat
  not sure why.  */
 
   info.name = ".debug_info";
-  info.start = dwarf_info;
-  info.buf = dwarf_info;
-  info.left = dwarf_info_size;
+  info.start = dwarf_sections->data[DEBUG_INFO];
+  info.buf = info.start;
+  info.left = dwarf_sections->size[DEBUG_INFO];
   info.is_bigendian = is_bigendian;
   info.error_callback = error_callback;
   info.data = data;
@@ -1583,7 +1571,9 @@ build_address_map (struct backtrace_stat
 
   memset (&u->abbrevs, 0, sizeof u->abbrevs);
   abbrev_offset = read_offset (&unit_buf, is_dwarf64);
-  if (!read_abbrevs (state, abbrev_offset, dwarf_abbrev, dwarf_abbrev_size,
+  if (!read_abbrevs (state, abbrev_offset,
+dwarf_sections->data[DEBUG_ABBREV],
+dwarf_sections->size[DEBUG_ABBREV],
 is_bigendian, error_callback, data, &u->abbrevs))
goto fail;
 
@@ -1610,8 +1600,10 @@ build_address_map (struct backtrace_stat
   u->function_addrs_count = 0;
 
   if (!find_address_ranges (state, base_address, &unit_buf,
-   dwarf_str, dwarf_str_size,
-

libbacktrace patch committed: Declare test1 in edtest.c with noclone

2019-12-04 Thread Ian Lance Taylor
This libbacktrace patch adds the noclone attribute to the version of
test1 in edtest.c, to correspond to other versions of test1.
Bootstrapped and ran libbacktrace tests on x86_64-pc-linux-gnu.
Committed to mainline.

Ian

2019-12-04  Ian Lance Taylor  

* edtest.c (test1): Add noclone attribute.
Index: edtest.c
===
--- edtest.c(revision 278944)
+++ edtest.c(working copy)
@@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.  */
 
 #include "testlib.h"
 
-static int test1 (void) __attribute__ ((noinline, unused));
-static int test1 (void) __attribute__ ((noinline, unused));
+static int test1 (void) __attribute__ ((noinline, noclone, unused));
 extern int f2 (int);
 extern int f3 (int, int);
 


libgo patch committed: Always mark assembly file as non-executable stack

2019-12-05 Thread Ian Lance Taylor
This libgo patch arranges for go-context.S to always be marked as
using a non-executable stack.  This is not required for all targets,
but should do little harm.  Bootstrapped on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 278984)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-017830d2a4bd2efbddf5e841ba9ccff8acf9d7c8
+a59794347b9db6dc2101a65c3e1a068051c0ee81
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/runtime/go-context.S
===
--- libgo/runtime/go-context.S  (revision 278984)
+++ libgo/runtime/go-context.S  (working copy)
@@ -66,8 +66,9 @@ __go_makecontext:
 
ret
 
-   .section.note.GNU-stack,"",@progbits
.section.note.GNU-split-stack,"",@progbits
.section.note.GNU-no-split-stack,"",@progbits
 
 #endif
+
+   .section.note.GNU-stack,"",@progbits


libgo patch committed: Recognize aarch64_be as arm64be

2019-12-05 Thread Ian Lance Taylor
This libgo patch recognizes aarch64_be as arm64be.  I don't know if
anything else is needed for aarch64_be support, but this at least is
required.  This is for GCC PR 92810.  Bootstrapped on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279010)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-a59794347b9db6dc2101a65c3e1a068051c0ee81
+e32651d37e0c43bb7595ac94363b079610bed746
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/configure.ac
===
--- libgo/configure.ac  (revision 278984)
+++ libgo/configure.ac  (working copy)
@@ -240,6 +240,9 @@ case ${host} in
   aarch64-*-*)
 GOARCH=arm64
 ;;
+  aarch64_be-*-*)
+GOARCH=arm64be
+;;
   arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
 GOARCH=arm
 case ${host} in


libgo patch committed: Update HURD support for embedded mOS

2019-12-06 Thread Ian Lance Taylor
In the update to 1.13 the mOS field of an m was embedded rather than
named.  This patch updates the HURD support for that change.  This
should fix GCC PR 92842.  I built the code on x86_64-pc-linux-gnu, but
that doesn't actually test this.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279032)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-e32651d37e0c43bb7595ac94363b079610bed746
+f04751699e1a1ce98fe8bdbcce5a00f1be6a7d15
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/os_hurd.go
===
--- libgo/go/runtime/os_hurd.go (revision 278984)
+++ libgo/go/runtime/os_hurd.go (working copy)
@@ -39,7 +39,7 @@ func sem_timedwait(sem *_sem_t, timeout
 
 //go:nosplit
 func semacreate(mp *m) {
-   if mp.mos.waitsema != 0 {
+   if mp.waitsema != 0 {
return
}
 
@@ -52,7 +52,7 @@ func semacreate(mp *m) {
if sem_init(sem, 0, 0) != 0 {
throw("sem_init")
}
-   mp.mos.waitsema = uintptr(unsafe.Pointer(sem))
+   mp.waitsema = uintptr(unsafe.Pointer(sem))
 }
 
 //go:nosplit
@@ -62,7 +62,7 @@ func semasleep(ns int64) int32 {
var ts timespec
ts.setNsec(ns)
 
-   if sem_timedwait((*_sem_t)(unsafe.Pointer(_m_.mos.waitsema)), 
&ts) != 0 {
+   if sem_timedwait((*_sem_t)(unsafe.Pointer(_m_.waitsema)), &ts) 
!= 0 {
err := errno()
if err == _ETIMEDOUT || err == _EAGAIN || err == _EINTR 
{
return -1
@@ -72,7 +72,7 @@ func semasleep(ns int64) int32 {
return 0
}
for {
-   r1 := sem_wait((*_sem_t)(unsafe.Pointer(_m_.mos.waitsema)))
+   r1 := sem_wait((*_sem_t)(unsafe.Pointer(_m_.waitsema)))
if r1 == 0 {
break
}
@@ -86,7 +86,7 @@ func semasleep(ns int64) int32 {
 
 //go:nosplit
 func semawakeup(mp *m) {
-   if sem_post((*_sem_t)(unsafe.Pointer(mp.mos.waitsema))) != 0 {
+   if sem_post((*_sem_t)(unsafe.Pointer(mp.waitsema))) != 0 {
throw("sem_post")
}
 }


Re: libgo patch committed: Always mark assembly file as non-executable stack

2019-12-06 Thread Ian Lance Taylor
Thanks, rather than try to make this work everywhere, I decided to
only build the file for x86 GNU/Linux for now, since that is the only
place it is currently used.  This patch bootstrapped on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279062)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-f04751699e1a1ce98fe8bdbcce5a00f1be6a7d15
+15c7bc9f0a432bc09716758412ea41d6caa6491b
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/Makefile.am
===
--- libgo/Makefile.am   (revision 278984)
+++ libgo/Makefile.am   (working copy)
@@ -414,6 +414,13 @@ else
 rtems_task_variable_add_file =
 endif
 
+runtime_context_asm_file =
+if LIBGO_IS_X86
+if LIBGO_IS_LINUX
+runtime_context_asm_file += runtime/go-context.S
+endif
+endif
+
 runtime_files = \
runtime/aeshash.c \
runtime/go-assert.c \
@@ -445,7 +452,7 @@ runtime_files = \
runtime/runtime_c.c \
runtime/stack.c \
runtime/yield.c \
-   runtime/go-context.S \
+   $(runtime_context_asm_file) \
$(rtems_task_variable_add_file)
 
 version.go: s-version; @true


libgo patch committed: Hurd fix

2019-12-08 Thread Ian Lance Taylor
I've committed this Hurd fix by Samuel Thibault for GCC PR 92861.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279063)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-15c7bc9f0a432bc09716758412ea41d6caa6491b
+1da5ceb8daaab7a243fffd6a647554cf674716f8
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/os_hurd.go
===
--- libgo/go/runtime/os_hurd.go (revision 279062)
+++ libgo/go/runtime/os_hurd.go (working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// This file is derived from os_solaris.go.
+// This file is derived from os_aix.go.
 
 package runtime
 
@@ -37,6 +37,10 @@ func sem_post(sem *_sem_t) int32
 //extern sem_timedwait
 func sem_timedwait(sem *_sem_t, timeout *timespec) int32
 
+//go:noescape
+//extern clock_gettime
+func clock_gettime(clock_id int32, timeout *timespec) int32
+
 //go:nosplit
 func semacreate(mp *m) {
if mp.waitsema != 0 {
@@ -60,7 +64,23 @@ func semasleep(ns int64) int32 {
_m_ := getg().m
if ns >= 0 {
var ts timespec
-   ts.setNsec(ns)
+
+   if clock_gettime(_CLOCK_REALTIME, &ts) != 0 {
+   throw("clock_gettime")
+   }
+
+   sec := int64(ts.tv_sec) + ns/1e9
+   nsec := int64(ts.tv_nsec) + ns%1e9
+   if nsec >= 1e9 {
+   sec++
+   nsec -= 1e9
+   }
+   if sec != int64(timespec_sec_t(sec)) {
+   // Handle overflows (timespec_sec_t is 32-bit in 32-bit 
applications)
+   sec = 1<<31 - 1
+   }
+   ts.tv_sec = timespec_sec_t(sec)
+   ts.tv_nsec = timespec_nsec_t(nsec)
 
if sem_timedwait((*_sem_t)(unsafe.Pointer(_m_.waitsema)), &ts) 
!= 0 {
err := errno()
@@ -105,3 +125,7 @@ func osinit() {
physPageSize = uintptr(getPageSize())
}
 }
+
+const (
+   _CLOCK_REALTIME = 0
+)


Re: libgo patch committed: Hurd fix

2019-12-09 Thread Ian Lance Taylor
On Sun, Dec 8, 2019 at 7:43 PM Ian Lance Taylor  wrote:
>
> I've committed this Hurd fix by Samuel Thibault for GCC PR 92861.

And a followup patch, also by Samuel Thibault.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279106)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-1da5ceb8daaab7a243fffd6a647554cf674716f8
+6f2bf15e15bf7516c393966577d72b79cba7f980
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/os_hurd.go
===
--- libgo/go/runtime/os_hurd.go (revision 279106)
+++ libgo/go/runtime/os_hurd.go (working copy)
@@ -125,7 +125,3 @@ func osinit() {
physPageSize = uintptr(getPageSize())
}
 }
-
-const (
-   _CLOCK_REALTIME = 0
-)


libbacktrace patch committed: Remove duplication of address handling

2019-12-09 Thread Ian Lance Taylor
Before this patch libbacktrace duplicated the handling of
DW_AT_low_pc, DW_AT_high_pc, and DW_AT_ranges, once to build a mapping
from addresses to compilation units, and then again to build a mapping
from addresses to functions within a compilation unit.  This patch
removes the duplication into a pair of functions, one of which takes a
function pointer to actually add the appropriate mapping.  This is a
step toward adding DWARF 5 support, as DWARF 5 requires handling more
cases here, and it seemed painful to introduce further duplication.
Bootstrapped and ran libbacktrace and Go testsuites on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: dwarf.c
===
--- dwarf.c (revision 279094)
+++ dwarf.c (working copy)
@@ -945,31 +945,28 @@ function_addrs_search (const void *vkey,
 return 0;
 }
 
-/* Add a new compilation unit address range to a vector.  Returns 1 on
-   success, 0 on failure.  */
+/* Add a new compilation unit address range to a vector.  This is
+   called via add_ranges.  Returns 1 on success, 0 on failure.  */
 
 static int
-add_unit_addr (struct backtrace_state *state, uintptr_t base_address,
-  struct unit_addrs addrs,
+add_unit_addr (struct backtrace_state *state, void *rdata,
+  uint64_t lowpc, uint64_t highpc,
   backtrace_error_callback error_callback, void *data,
-  struct unit_addrs_vector *vec)
+  void *pvec)
 {
+  struct unit *u = (struct unit *) rdata;
+  struct unit_addrs_vector *vec = (struct unit_addrs_vector *) pvec;
   struct unit_addrs *p;
 
-  /* Add in the base address of the module here, so that we can look
- up the PC directly.  */
-  addrs.low += base_address;
-  addrs.high += base_address;
-
   /* Try to merge with the last entry.  */
   if (vec->count > 0)
 {
   p = (struct unit_addrs *) vec->vec.base + (vec->count - 1);
-  if ((addrs.low == p->high || addrs.low == p->high + 1)
- && addrs.u == p->u)
+  if ((lowpc == p->high || lowpc == p->high + 1)
+ && u == p->u)
{
- if (addrs.high > p->high)
-   p->high = addrs.high;
+ if (highpc > p->high)
+   p->high = highpc;
  return 1;
}
 }
@@ -980,8 +977,12 @@ add_unit_addr (struct backtrace_state *s
   if (p == NULL)
 return 0;
 
-  *p = addrs;
+  p->low = lowpc;
+  p->high = highpc;
+  p->u = u;
+
   ++vec->count;
+
   return 1;
 }
 
@@ -1262,29 +1263,122 @@ lookup_abbrev (struct abbrevs *abbrevs,
   return (const struct abbrev *) p;
 }
 
-/* Add non-contiguous address ranges for a compilation unit.  Returns
-   1 on success, 0 on failure.  */
+/* This struct is used to gather address range information while
+   reading attributes.  We use this while building a mapping from
+   address ranges to compilation units and then again while mapping
+   from address ranges to function entries.  Normally either
+   lowpc/highpc is set or ranges is set.  */
+
+struct pcrange {
+  uint64_t lowpc;  /* The low PC value.  */
+  int have_lowpc;  /* Whether a low PC value was found.  */
+  uint64_t highpc; /* The high PC value.  */
+  int have_highpc; /* Whether a high PC value was found.  */
+  int highpc_is_relative;  /* Whether highpc is relative to lowpc.  */
+  uint64_t ranges; /* Offset in ranges section.  */
+  int have_ranges; /* Whether ranges is valid.  */
+};
+
+/* Update PCRANGE from an attribute value.  */
+
+static void
+update_pcrange (const struct attr* attr, const struct attr_val* val,
+   struct pcrange *pcrange)
+{
+  switch (attr->name)
+{
+case DW_AT_low_pc:
+  if (val->encoding == ATTR_VAL_ADDRESS)
+   {
+ pcrange->lowpc = val->u.uint;
+ pcrange->have_lowpc = 1;
+   }
+  break;
+
+case DW_AT_high_pc:
+  if (val->encoding == ATTR_VAL_ADDRESS)
+   {
+ pcrange->highpc = val->u.uint;
+ pcrange->have_highpc = 1;
+   }
+  else if (val->encoding == ATTR_VAL_UINT)
+   {
+ pcrange->highpc = val->u.uint;
+ pcrange->have_highpc = 1;
+ pcrange->highpc_is_relative = 1;
+   }
+  break;
+
+case DW_AT_ranges:
+  if (val->encoding == ATTR_VAL_UINT
+ || val->encoding == ATTR_VAL_REF_SECTION)
+   {
+ pcrange->ranges = val->u.uint;
+ pcrange->have_ranges = 1;
+   }
+  break;
+
+default:
+  break;
+}
+}
+
+/* Call ADD_RANGE for each lowpc/highpc pair in PCRANGE.  RDATA is
+   passed to ADD_RANGE, and is either a struct unit * or a struct
+   function *.  VEC is the vector we are adding ranges to, and is
+   either a struct unit_addrs_vector * or a struct function_vector *.
+   Returns 1 on success, 0 on error.  */
 
 static int
-add_unit_ranges (struct backtrace_state *state, uintptr_t base_address,
-struct unit *u, uint64_t ranges, uint64

Go patch committed: Build type descriptor for alias in other package

2019-12-10 Thread Ian Lance Taylor
This patch to the Go frontend by Cherry Zhang generates type
descriptors for pointers to aliases defined in other packages.  When a
type descriptor is needed (for e.g. interface conversion), if the type
is a pointer to a named type defined in another package, we don't
generate the definition of the type descriptor because it is generated
in the package where the type is defined.  However, if the named type
is an alias to an unnamed type, its descriptor is not generated in the
other package, and we need to generate it.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279136)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-6f2bf15e15bf7516c393966577d72b79cba7f980
+85641a0f26061f7c98db42a2adb3250c07ce504e
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc  (revision 278984)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -1453,13 +1453,13 @@ Type::type_descriptor_defined_elsewhere(
   else
 {
   if (this->points_to() != NULL
- && this->points_to()->named_type() != NULL
- && this->points_to()->named_type()->named_object()->package() != NULL)
+ && this->points_to()->unalias()->named_type() != NULL
+ && 
this->points_to()->unalias()->named_type()->named_object()->package() != NULL)
{
  // This is an unnamed pointer to a named type defined in a
  // different package.  The descriptor should be defined in
  // that package.
- *package = this->points_to()->named_type()->named_object()->package();
+ *package = 
this->points_to()->unalias()->named_type()->named_object()->package();
  return true;
}
 }


libbacktrace patch committed: Add DWARF 5 support

2019-12-13 Thread Ian Lance Taylor
This patch to libbacktrace adds DWARF 5 support.  I tested this with
GCC 8, GCC tip, and clang 8, using the -gdwarf-5 option.  Bootstrapped
and ran libbacktrace and libgo tests on x86_64-pc-linux-gnu.
Committed to mainline.

Ian

2019-12-13  Ian Lance Taylor  

Add DWARF 5 support.
* dwarf.c (struct attr): Add val field.
(enum attr_val_encoding): Add ATTR_VAL_ADDDRESS_INDEX,
ATTR_VAL_STRING_INDEX, ATTR_VAL_RNGLISTS_INDEX.
(struct line_header): Add addrsize field.
(struct line_header_format): Define.
(struct unit): Add str_offsets_base, addr_base, and rnglists_base
fields.
(read_uint24): New static function.
(read_attribute): Add implicit_val parameter.  Replace dwarf_str
and dwarf_str_size parameters with dwarf_sections parameter.  Add
support for new DWARF 5 forms.  Change all callers.
(resolve_string): New static function.
(resolve_addr_index): Likewise.
(read_abbrevs): Support DW_FORM_implicit_const.
(struct pcrange): Add lowpc_is_addr_index, highpc_is_addr_Index,
and ranges_is_index fields.
(update_pcrange): Support DWARF 5 encodings.
(add_high_low_range): New static function, split out of
add_ranges.
(add_ranges_from_ranges): Likewise.
(add_ranges_from_rnglists): New static function.
(add_ranges): Just call new helper functions.
(find_address_ranges): Use resolve_string for strings, after
reading all attributes.  Handle new DWARF 5 attributes.
(build_address_map): Support DWARF 5 compilation units.
(read_v2_paths): New static function, split out of
read_line_header.
(read_lnct): New static function.
(read_line_header_format_entries): Likewise.
(read_line_header): Add ddata parameter.  Support DWARF 5 line
headers.  Call new helper functions.  Change all callers.
(read_line_program): Use addrsize from line program header.  Don't
special case directory index 0 for DWARF 5.
(read_referenced_name): Use resolve_string.
(read_function_entry): Handle DWARF 5 encodings.  Use
resolve_string.
* internal.h (enum dwarf_section): Add DEBUG_ADDR,
DEBUG_STR_OFFSETS, DEBUG_LINE_STR, DEBUG_RNGLISTS.
* elf.c (dwarf_section_names): Add new section names.
* pecoff.c (dwarf_section_names): Likewise.
* xcoff.c (xcoff_add): Clear dwarf_sections before setting
fields.
* configure.ac: Define HAVE_DWARF5 automake conditional.
* Makefile.am (dwarf5_SOURCES): New variable if HAVE_DWARF5.
(dwarf5_CFLAGS, dwarf5_LDADD): Likewise.
(dwarf5_alloc_SOURCES, dwarf5_alloc_CFLAGS): Likewise.
(dwarf5_alloc_LDADD): Likewise.
(BUILDTESTS): Add dwarf5 tests if HAVE_DWARF5.
(CLEANFILES, clean-local): Define.
Index: Makefile.am
===
--- Makefile.am (revision 279211)
+++ Makefile.am (working copy)
@@ -385,12 +385,33 @@ BUILDTESTS += ctestg_alloc ctesta_alloc
 
 endif
 
+if HAVE_DWARF5
+
+dwarf5_SOURCES = btest.c testlib.c
+dwarf5_CFLAGS = $(AM_CFLAGS) -gdwarf-5
+dwarf5_LDADD = libbacktrace.la
+
+BUILDTESTS += dwarf5
+
+dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
+dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
+dwarf5_alloc_LDADD = libbacktrace_alloc.la
+
+BUILDTESTS += dwarf5_alloc
+
+endif
+
 endif NATIVE
 
 check_PROGRAMS += $(BUILDTESTS)
 
 TESTS += $(BUILDTESTS)
 
+CLEANFILES = $(TESTS) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build
+
+clean-local:
+   -rm -rf usr
+
 # We can't use automake's automatic dependency tracking, because it
 # breaks when using bootstrap-lean.  Automatic dependency tracking
 # with GCC bootstrap will cause some of the objects to depend on
Index: configure.ac
===
--- configure.ac(revision 279211)
+++ configure.ac(working copy)
@@ -420,6 +420,17 @@ AC_SUBST(PTHREAD_CFLAGS)
 
 AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
 
+dnl Test whether the compiler supports the -gdwarf-5 option.
+AC_CACHE_CHECK([whether -gdwarf-5 is supported],
+[libbacktrace_cv_lib_dwarf5],
+[CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -gdwarf-5"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
+[libbacktrace_cv_lib_dwarf5=yes],
+[libbacktrace_cv_lib_dwarf5=no])
+CFLAGS=$CFLAGS_hold])
+AM_CONDITIONAL(HAVE_DWARF5, test "$libbacktrace_cv_lib_dwarf5" = yes)
+
 AC_CHECK_LIB([z], [compress],
 [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
 AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
Index: dwarf.c
===
--- dwarf.c (revision 279211)
+++ dwarf.c (working copy)
@@ -92,6 +92,8 @@ struct attr
   enum dwarf_attribute name;
   /* The attribute form.  */
   enum dwarf_form form;
+  /* The attribute value, for DW_FORM_implicit_const.  */
+  int64_t val;
 };
 
 /* A single DWARF abbreviation.  */
@@ -133,22 +135,29 @@ enum attr_val_encoding
   ATTR_VAL_NONE,
   /* An address.  */
   ATTR_VAL_ADDRESS,
+  /* An index into the .debug_addr section, whose value is relative to
+   * the DW_AT_addr_base attribute of the compilation unit. 

gccgo branch updated

2019-12-13 Thread Ian Lance Taylor
I've updated the gccgo branch to revision 279380 of trunk.

Ian


Re: gccgo branch updated

2019-12-18 Thread Ian Lance Taylor
I've updated the gccgo branch to revision 279561 of trunk.

Ian


libgo patch committed: Hurd portability patches

2019-12-23 Thread Ian Lance Taylor
This libgo patch by Svante Signell adds some Hurd portability patches
to libgo.  These are from GCC PR 93020.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279398)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-85641a0f26061f7c98db42a2adb3250c07ce504e
+393957c8b68e370504209eb901aa0c3874e256d4
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/internal/poll/errno_unix.go
===
--- libgo/go/internal/poll/errno_unix.go(revision 279398)
+++ libgo/go/internal/poll/errno_unix.go(working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd hurd linux netbsd openbsd solaris
 
 package poll
 
Index: libgo/go/os/export_unix_test.go
===
--- libgo/go/os/export_unix_test.go (revision 279398)
+++ libgo/go/os/export_unix_test.go (working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd 
solaris
+// +build aix darwin dragonfly freebsd hurd js,wasm linux nacl netbsd openbsd 
solaris
 
 package os
 
Index: libgo/go/runtime/os_hurd.go
===
--- libgo/go/runtime/os_hurd.go (revision 279398)
+++ libgo/go/runtime/os_hurd.go (working copy)
@@ -112,7 +112,7 @@ func semawakeup(mp *m) {
 }
 
 func getncpu() int32 {
-   n := int32(sysconf(_SC_NPROCESSORS_ONLN))
+   n := int32(sysconf(__SC_NPROCESSORS_ONLN))
if n < 1 {
return 1
}
Index: libgo/go/syscall/export_unix_test.go
===
--- libgo/go/syscall/export_unix_test.go(revision 279398)
+++ libgo/go/syscall/export_unix_test.go(working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd hurd linux netbsd openbsd solaris
 
 package syscall
 


Go patch committed: Split writing of equal and hash functions for types

2020-01-02 Thread Ian Lance Taylor
This patch to the Go frontend splits the writing of equal and hash
functions for types, rather than doing them in a single operation.
This is almost entirely a pure refactoring in preparation for
generating hash functions only for types that are map keys.  The only
change in generated code is that for types that are the size of
numeric types, but not aligned like numeric types, such as [8]byte,
now use standard hash functions.  They previously used special-purpose
hash functions because they required special-purpose equal functions.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279815)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-393957c8b68e370504209eb901aa0c3874e256d4
+b5c950fb98042fe434edca0c2403234692f25cd4
 
 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 279815)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -6238,10 +6238,8 @@ Binary_expression::lower_array_compariso
 return this->lower_compare_to_memcmp(gogo, inserter);
 
   // Call the array comparison function.
-  Named_object* hash_fn;
-  Named_object* equal_fn;
-  at->type_functions(gogo, this->left_->type()->named_type(), NULL, NULL,
-&hash_fn, &equal_fn);
+  Named_object* equal_fn =
+at->equal_function(gogo, this->left_->type()->named_type(), NULL);
 
   Location loc = this->location();
 
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 279815)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -2717,23 +2717,40 @@ Gogo::clear_file_scope()
   this->current_file_imported_unsafe_ = false;
 }
 
-// Queue up a type specific function for later writing.  These are
-// written out in write_specific_type_functions, called after the
+// Queue up a type-specific hash function for later writing.  These
+// are written out in write_specific_type_functions, called after the
 // parse tree is lowered.
 
 void
-Gogo::queue_specific_type_function(Type* type, Named_type* name, int64_t size,
-  const std::string& hash_name,
-  Function_type* hash_fntype,
-  const std::string& equal_name,
-  Function_type* equal_fntype)
+Gogo::queue_hash_function(Type* type, Named_type* name, int64_t size,
+ const std::string& hash_name,
+ Function_type* hash_fntype)
 {
   go_assert(!this->specific_type_functions_are_written_);
   go_assert(!this->in_global_scope());
+  Specific_type_function::Specific_type_function_kind kind =
+Specific_type_function::SPECIFIC_HASH;
   Specific_type_function* tsf = new Specific_type_function(type, name, size,
-  hash_name,
-  hash_fntype,
-  equal_name,
+  kind, hash_name,
+  hash_fntype);
+  this->specific_type_functions_.push_back(tsf);
+}
+
+// Queue up a type-specific equal function for later writing.  These
+// are written out in write_specific_type_functions, called after the
+// parse tree is lowered.
+
+void
+Gogo::queue_equal_function(Type* type, Named_type* name, int64_t size,
+  const std::string& equal_name,
+  Function_type* equal_fntype)
+{
+  go_assert(!this->specific_type_functions_are_written_);
+  go_assert(!this->in_global_scope());
+  Specific_type_function::Specific_type_function_kind kind =
+Specific_type_function::SPECIFIC_EQUAL;
+  Specific_type_function* tsf = new Specific_type_function(type, name, size,
+  kind, equal_name,
   equal_fntype);
   this->specific_type_functions_.push_back(tsf);
 }
@@ -2758,8 +2775,6 @@ class Specific_type_functions : public T
 int
 Specific_type_functions::type(Type* t)
 {
-  Named_object* hash_fn;
-  Named_object* equal_fn;
   switch (t->classification())
 {
 case Type::TYPE_NAMED:
@@ -2768,7 +2783,10 @@ Specific_type_functions::type(Type* t)
if (nt->is_alias())
  return TRAVERSE_CONTINUE;
if (t->needs_specific_type_functions(this->gogo_))
- t->type_functions(this->gogo_, nt, NULL, NULL, &hash_fn, &equal_fn);
+ {
+   t->equal_function(this->gogo_, nt, NULL);
+   t->

Go patch committed: Generate hash functions only for map keys

2020-01-02 Thread Ian Lance Taylor
This patch to the Go frontend and libgo changes the compiler to only
generate hash functions for types used as map keys.

Right now we generate hash functions for all types, just in case they
are used as map keys. That's a lot of wasted effort and binary size
for types which will never be used as a map key. Instead, generate
hash functions only for types that we know are map keys.

Just doing that is a bit too simple, since maps with an interface type
as a key might have to hash any concrete key type that implements that
interface.  So for that case, implement hashing of such types at
runtime (instead of with generated code). It will be slower, but only
for maps with interface types as keys, and maybe only a bit slower as
the aeshash time probably dominates the dispatch time.

Reorg where we keep the equals and hash functions.  Move the hash
function from the key type to the map type, saving a field in every
non-map type.  That leaves only one function in the alg structure, so
get rid of that and just keep the equal function in the type
descriptor itself.

While we're here, reorganize the rtype struct to more closely match
the gc version.

This is the gofrontend version of https://golang.org/cl/191198.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279847)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-b5c950fb98042fe434edca0c2403234692f25cd4
+9163fa28b89222cd851c0d24bd6a1384d1379c55
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 279847)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -2722,7 +2722,7 @@ Gogo::clear_file_scope()
 // parse tree is lowered.
 
 void
-Gogo::queue_hash_function(Type* type, Named_type* name, int64_t size,
+Gogo::queue_hash_function(Type* type, int64_t size,
  const std::string& hash_name,
  Function_type* hash_fntype)
 {
@@ -2730,7 +2730,7 @@ Gogo::queue_hash_function(Type* type, Na
   go_assert(!this->in_global_scope());
   Specific_type_function::Specific_type_function_kind kind =
 Specific_type_function::SPECIFIC_HASH;
-  Specific_type_function* tsf = new Specific_type_function(type, name, size,
+  Specific_type_function* tsf = new Specific_type_function(type, NULL, size,
   kind, hash_name,
   hash_fntype);
   this->specific_type_functions_.push_back(tsf);
@@ -2783,10 +2783,7 @@ Specific_type_functions::type(Type* t)
if (nt->is_alias())
  return TRAVERSE_CONTINUE;
if (t->needs_specific_type_functions(this->gogo_))
- {
-   t->equal_function(this->gogo_, nt, NULL);
-   t->hash_function(this->gogo_, nt, NULL);
- }
+ t->equal_function(this->gogo_, nt, NULL);
 
// If this is a struct type, we don't want to make functions
// for the unnamed struct.
@@ -2820,10 +2817,15 @@ Specific_type_functions::type(Type* t)
 case Type::TYPE_STRUCT:
 case Type::TYPE_ARRAY:
   if (t->needs_specific_type_functions(this->gogo_))
-   {
- t->equal_function(this->gogo_, NULL, NULL);
- t->hash_function(this->gogo_, NULL, NULL);
-   }
+   t->equal_function(this->gogo_, NULL, NULL);
+  break;
+
+case Type::TYPE_MAP:
+  {
+   Type* key_type = t->map_type()->key_type();
+   if (key_type->needs_specific_type_functions(this->gogo_))
+ key_type->hash_function(this->gogo_, NULL);
+  }
   break;
 
 default:
@@ -2846,8 +2848,8 @@ Gogo::write_specific_type_functions()
   Specific_type_function* tsf = this->specific_type_functions_.back();
   this->specific_type_functions_.pop_back();
   if (tsf->kind == Specific_type_function::SPECIFIC_HASH)
-   tsf->type->write_hash_function(this, tsf->name, tsf->size,
-  tsf->fnname, tsf->fntype);
+   tsf->type->write_hash_function(this, tsf->size, tsf->fnname,
+  tsf->fntype);
   else
tsf->type->write_equal_function(this, tsf->name, tsf->size,
tsf->fnname, tsf->fntype);
Index: gcc/go/gofrontend/gogo.h
===
--- gcc/go/gofrontend/gogo.h(revision 279847)
+++ gcc/go/gofrontend/gogo.h(working copy)
@@ -602,8 +602,7 @@ class Gogo
   // is used when a type-specific hash function is needed when not at
   // top level.
   void
-  queue_hash_function(Type* type, Named_type* name, int64_t size,
- const std::string& hash_name,
+  queue

Go patch committed: Avoid a couple of compiler crashes

2020-01-07 Thread Ian Lance Taylor
This patch to the Go frontend avoids a couple of compiler crashes.
These came up while building 1.14beta1 while the code was still
invalid.  The general policy is to not bother committing invalid test
cases that cause compiler crashes.  Bootstrapped and ran Go tests on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279848)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-9163fa28b89222cd851c0d24bd6a1384d1379c55
+d0a102eea2262e3fca89b1eb342fd03328c4aa16
 
 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 279847)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -11766,10 +11766,17 @@ Call_expression::do_add_conversions()
   Typed_identifier_list::const_iterator pp = fntype->parameters()->begin();
   bool is_interface_method =
 this->fn_->interface_field_reference_expression() != NULL;
+  size_t argcount = this->args_->size();
   if (!is_interface_method && fntype->is_method())
 {
   // Skip the receiver argument, which cannot be interface.
   pa++;
+  argcount--;
+}
+  if (argcount != fntype->parameters()->size())
+{
+  go_assert(saw_errors());
+  return;
 }
   for (; pa != this->args_->end(); ++pa, ++pp)
 {
@@ -11895,6 +11902,8 @@ Call_expression::is_erroneous_call()
 Type*
 Call_expression::do_type()
 {
+  if (this->is_error_expression())
+return Type::make_error_type();
   if (this->type_ != NULL)
 return this->type_;
 


Go patch committed: Avoid write barrier for a[i] = a[i][:v]

2020-01-07 Thread Ian Lance Taylor
This patch to the Go frontend avoids generating a write barrier for
code that appears in the Go1.14beta1 runtime package in
(*pageAlloc).sysGrow:
s.summary[l] = s.summary[l][:needIdxLimit]
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279956)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-d0a102eea2262e3fca89b1eb342fd03328c4aa16
+86d223eaccecff72b44cd23a014bc028b658055e
 
 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 279956)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -183,6 +183,24 @@ Expression::is_same_variable(Expression*
  bu->operand()));
 }
 
+  Array_index_expression* aie = a->array_index_expression();
+  if (aie != NULL)
+{
+  Array_index_expression* bie = b->array_index_expression();
+  return (aie->end() == NULL
+ && bie->end() == NULL
+ && Expression::is_same_variable(aie->array(), bie->array())
+ && Expression::is_same_variable(aie->start(), bie->start()));
+}
+
+  Numeric_constant aval;
+  if (a->numeric_constant_value(&aval))
+{
+  Numeric_constant bval;
+  if (b->numeric_constant_value(&bval))
+   return aval.equals(bval);
+}
+
   return false;
 }
 


Go patch committed: Stop using __go_runtime_error

2020-01-07 Thread Ian Lance Taylor
This patch to the Go frontend and libgo stops using
__go_runtime_error.  We use specific panic functions instead, which
are mostly already in the runtime package.  We also correct "defer
nil" to panic when we execute the defer, rather than throw when we
queue it.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279962)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-86d223eaccecff72b44cd23a014bc028b658055e
+6fa9657df508ff4d7760cf1abfad3611ba808561
 
 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 279962)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -5270,13 +5270,13 @@ Unary_expression::do_get_backend(Transla
 Bexpression* compare =
 gogo->backend()->binary_expression(OPERATOR_EQEQ, tbexpr,
nil, loc);
-Bexpression* crash =
-gogo->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE,
-loc)->get_backend(context);
+   Expression* crash = Runtime::make_call(Runtime::PANIC_MEM,
+  loc, 0);
+   Bexpression* bcrash = crash->get_backend(context);
 Bfunction* bfn = context->function()->func_value()->get_decl();
 bexpr = gogo->backend()->conditional_expression(bfn, btype,
 compare,
-crash, ubexpr,
+bcrash, ubexpr,
 loc);
 known_valid = true;
 break;
@@ -7060,12 +7060,12 @@ Binary_expression::do_get_backend(Transl
  Bexpression* compare =
gogo->backend()->binary_expression(OPERATOR_LT, right, zero_expr,
   loc);
- const int errcode = RUNTIME_ERROR_SHIFT_BY_NEGATIVE;
- Bexpression* crash =
-   gogo->runtime_error(errcode, loc)->get_backend(context);
+ Expression* crash = Runtime::make_call(Runtime::PANIC_SHIFT,
+loc, 0);
+ Bexpression* bcrash = crash->get_backend(context);
  Bfunction* bfn = context->function()->func_value()->get_decl();
  ret = gogo->backend()->conditional_expression(bfn, btype, compare,
-   crash, ret, loc);
+   bcrash, ret, loc);
}
 }
 
@@ -7081,15 +7081,14 @@ Binary_expression::do_get_backend(Transl
   gogo->backend()->binary_expression(OPERATOR_EQEQ,
  right, zero_expr, loc);
 
- // __go_runtime_error(RUNTIME_ERROR_DIVISION_BY_ZERO)
- int errcode = RUNTIME_ERROR_DIVISION_BY_ZERO;
- Bexpression* crash = gogo->runtime_error(errcode,
-  loc)->get_backend(context);
+ Expression* crash = Runtime::make_call(Runtime::PANIC_DIVIDE,
+loc, 0);
+ Bexpression* bcrash = crash->get_backend(context);
 
- // right == 0 ? (__go_runtime_error(...), 0) : ret
+ // right == 0 ? (panicdivide(), 0) : ret
   Bfunction* bfn = context->function()->func_value()->get_decl();
   ret = gogo->backend()->conditional_expression(bfn, btype,
-check, crash,
+check, bcrash,
ret, loc);
}
 
@@ -8071,8 +8070,7 @@ Bound_method_expression::do_flatten(Gogo
 
   if (nil_check != NULL)
 {
-  Expression* crash = gogo->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE,
- loc);
+  Expression* crash = Runtime::make_call(Runtime::PANIC_MEM, loc, 0);
   // Fix the type of the conditional expression by pretending to
   // evaluate to RET either way through the conditional.
   crash = Expression::make_compound(crash, ret, loc);
@@ -8886,11 +8884,8 @@ Builtin_call_expression::flatten_append(
   Expression* zero = Expression::make_integer_ul(0, int_type, loc);
   Expression* cond = Expression::make_binary(OPERATOR_LT, len2,
  zero, loc);
-  Expression* arg =
-

Go patch committed: Fix loopdepth tracking in array slice

2020-01-07 Thread Ian Lance Taylor
This Go frontend patch by Cherry Zhang fixes the loopdepth tracking in
array slicing expressions in escape analysis.  In the gc compiler, for
slicing an array, its AST has an implicit address operation node.
There isn't such a node in the gofrontend AST.  During escape
analysis, we create a fake node to mimic the gc compiler's behavior.
For the fake node, the loopdepth was not tracked correctly, causing
miscompilation.  Since this is an address operation, do the same thing
as we do for the address operator.  This fixes
https://golang.org/issue/36404.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to trunk and GCC 9 branch.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 279979)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-6fa9657df508ff4d7760cf1abfad3611ba808561
+e0790a756e9ba77e2d3d6ef5d0abbb11dd71211b
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/escape.cc
===
--- gcc/go/gofrontend/escape.cc (revision 279815)
+++ gcc/go/gofrontend/escape.cc (working copy)
@@ -1906,7 +1906,8 @@ Escape_analysis_assign::expression(Expre
 this->context_->track(addr_node);
 
 Node::Escape_state* addr_state = addr_node->state(this->context_, 
NULL);
-addr_state->loop_depth = array_state->loop_depth;
+if (array_state->loop_depth != 0)
+  addr_state->loop_depth = array_state->loop_depth;
   }
   }
   break;


Re: [PATCH] tree-ssa-dse: Fix up go.test/test/fixedbugs/issue16095.go miscompilation [PR100382]

2021-05-03 Thread Ian Lance Taylor
Jakub Jelinek  writes:

> The new DCE code inside of tree DSE removes in -fnon-call-exceptions
> go code a load from NULL pointer the testcase relies on throwing an
> exception and so the test hangs.
>
> The following patch just repeats a check that e.g. tree-ssa-dce.c
> uses to prevent this.

Thanks for tracking this down.

Ian


libbacktrace patch committed: Read symbol table of debuginfo file

2024-02-29 Thread Ian Lance Taylor
This patch to libbacktrace reads symbol tables from debuginfo files.
These become another symbol table to search.  This is needed if people
use --strip-all rather than --strip-debug when adding a debuglink
section.  This fixes
https://github.com/ianlancetaylor/libbacktrace/issues/113.
Bootstrapped and ran libbacktrace and libgo tests on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

* elf.c (elf_add): Add the symbol table from a debuginfo file.
* Makefile.am (MAKETESTS): Add buildidfull and gnudebuglinkfull
variants of buildid and gnudebuglink tests.
(%_gnudebuglinkfull, %_buildidfull): New patterns.
* Makefile.in: Regenerate.
24810fbf7b0ce274dfa46cc362305ac77ee5a72c
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 16a72d2abf7..750ed80ed05 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -257,7 +257,7 @@ b2test_LDFLAGS = -Wl,--build-id
 b2test_LDADD = libbacktrace_elf_for_test.la
 
 check_PROGRAMS += b2test
-MAKETESTS += b2test_buildid
+MAKETESTS += b2test_buildid b2test_buildidfull
 
 if HAVE_DWZ
 
@@ -267,7 +267,7 @@ b3test_LDFLAGS = -Wl,--build-id
 b3test_LDADD = libbacktrace_elf_for_test.la
 
 check_PROGRAMS += b3test
-MAKETESTS += b3test_dwz_buildid
+MAKETESTS += b3test_dwz_buildid b3test_dwz_buildidfull
 
 endif HAVE_DWZ
 
@@ -443,12 +443,16 @@ endif HAVE_PTHREAD
 
 if HAVE_OBJCOPY_DEBUGLINK
 
-MAKETESTS += btest_gnudebuglink
+MAKETESTS += btest_gnudebuglink btest_gnudebuglinkfull
 
 %_gnudebuglink: %
$(OBJCOPY) --only-keep-debug $< $@.debug
$(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
 
+%_gnudebuglinkfull: %
+   $(OBJCOPY) --only-keep-debug $< $@.debug
+   $(OBJCOPY) --strip-all --add-gnu-debuglink=$@.debug $< $@
+
 endif HAVE_OBJCOPY_DEBUGLINK
 
 %_buildid: %
@@ -457,6 +461,12 @@ endif HAVE_OBJCOPY_DEBUGLINK
  $<
$(OBJCOPY) --strip-debug $< $@
 
+%_buildidfull: %
+   ./install-debuginfo-for-buildid.sh \
+ "$(TEST_BUILD_ID_DIR)" \
+ $<
+   $(OBJCOPY) --strip-all $< $@
+
 if HAVE_COMPRESSED_DEBUG
 
 ctestg_SOURCES = btest.c testlib.c
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index c506cc29fe1..664937e1438 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -6872,7 +6872,7 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
 
   if (symtab_shndx == 0)
 symtab_shndx = dynsym_shndx;
-  if (symtab_shndx != 0 && !debuginfo)
+  if (symtab_shndx != 0)
 {
   const b_elf_shdr *symtab_shdr;
   unsigned int strtab_shndx;


Re: libbacktrace patch committed: Read symbol table of debuginfo file

2024-03-01 Thread Ian Lance Taylor
On Thu, Feb 29, 2024 at 7:47 PM Ian Lance Taylor  wrote:
>
> This patch to libbacktrace reads symbol tables from debuginfo files.
> These become another symbol table to search.  This is needed if people
> use --strip-all rather than --strip-debug when adding a debuglink
> section.  This fixes
> https://github.com/ianlancetaylor/libbacktrace/issues/113.
> Bootstrapped and ran libbacktrace and libgo tests on
> x86_64-pc-linux-gnu.  Committed to mainline.

This introduced a bug on the PPC v1 ABI, where libbacktrace uses the
.opd section to convert from a function descriptor address to a code
address.  The .opd section is missing from a debuginfo file.  This
patch changes the code to use the original .opd section if it is
missing.  Checked on powerpc64-linux-gnu and x86_64-pc-linux-gnu.
Committed to mainline.

Ian

PR libbacktrace/114201
* elf.c (elf_add): Add caller_opd parameter.  Change all callers.
Release opd data after all recursive calls.
f692b338cd27a4e0d38fcb5af3d416cd66fbf814
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 664937e1438..f4527e2477d 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -6501,8 +6501,9 @@ backtrace_uncompress_lzma (struct backtrace_state *state,
 static int
 elf_add (struct backtrace_state *state, const char *filename, int descriptor,
 const unsigned char *memory, size_t memory_size,
-uintptr_t base_address, backtrace_error_callback error_callback,
-void *data, fileline *fileline_fn, int *found_sym, int *found_dwarf,
+uintptr_t base_address, struct elf_ppc64_opd_data *caller_opd,
+backtrace_error_callback error_callback, void *data,
+fileline *fileline_fn, int *found_sym, int *found_dwarf,
 struct dwarf_data **fileline_entry, int exe, int debuginfo,
 const char *with_buildid_data, uint32_t with_buildid_size)
 {
@@ -6557,6 +6558,7 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
   struct elf_view split_debug_view[DEBUG_MAX];
   unsigned char split_debug_view_valid[DEBUG_MAX];
   struct elf_ppc64_opd_data opd_data, *opd;
+  int opd_view_valid;
   struct dwarf_sections dwarf_sections;
 
   if (!debuginfo)
@@ -6584,6 +6586,7 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
   debug_view_valid = 0;
   memset (&split_debug_view_valid[0], 0, sizeof split_debug_view_valid);
   opd = NULL;
+  opd_view_valid = 0;
 
   if (!elf_get_view (state, descriptor, memory, memory_size, 0, sizeof ehdr,
 error_callback, data, &ehdr_view))
@@ -6867,9 +6870,15 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
  opd->addr = shdr->sh_addr;
  opd->data = (const char *) opd_data.view.view.data;
  opd->size = shdr->sh_size;
+ opd_view_valid = 1;
}
 }
 
+  // A debuginfo file may not have a useful .opd section, but we can use the
+  // one from the original executable.
+  if (opd == NULL)
+opd = caller_opd;
+
   if (symtab_shndx == 0)
 symtab_shndx = dynsym_shndx;
   if (symtab_shndx != 0)
@@ -6948,9 +6957,9 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
elf_release_view (state, &debuglink_view, error_callback, data);
  if (debugaltlink_view_valid)
elf_release_view (state, &debugaltlink_view, error_callback, data);
- ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
-data, fileline_fn, found_sym, found_dwarf, NULL, 0,
-1, NULL, 0);
+ ret = elf_add (state, "", d, NULL, 0, base_address, opd,
+error_callback, data, fileline_fn, found_sym,
+found_dwarf, NULL, 0, 1, NULL, 0);
  if (ret < 0)
backtrace_close (d, error_callback, data);
  else if (descriptor >= 0)
@@ -6965,12 +6974,6 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
   buildid_view_valid = 0;
 }
 
-  if (opd)
-{
-  elf_release_view (state, &opd->view, error_callback, data);
-  opd = NULL;
-}
-
   if (debuglink_name != NULL)
 {
   int d;
@@ -6985,9 +6988,9 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
  elf_release_view (state, &debuglink_view, error_callback, data);
  if (debugaltlink_view_valid)
elf_release_view (state, &debugaltlink_view, error_callback, data);
- ret = elf_add (state, "", d, NULL, 0, base_address, error_callback,
-data, fileline_fn, found_sym, found_dwarf, NULL, 0,
-1, NULL, 0);
+ ret = elf_add (state, "", d, NULL, 0, base_address, opd,
+error_callback, data, fileline_fn, found_sym,
+found_dwarf, N

libbacktrace patch committed: Skip all LZMA block header padding bytes

2024-03-02 Thread Ian Lance Taylor
This patch to libbacktrace corrects the LZMA block header parsing to
skip all the padding bytes, verifying that they are zero.  This fixes
https://github.com/ianlancetaylor/libbacktrace/issues/118.
Bootstrapped and ran libbacktrace tests on x86_64-pc-linux-gnu.  I was
able to verify that the problem occurred when setting the environment
variable XZ_OPT="--threads=2", and that this patch fixes the bug.
Committed to mainline.

Ian

* elf.c (elf_uncompress_lzma_block): Skip all header padding bytes
and verify that they are zero.
23f9fbed3c97ed70d2615d7d3fa7c249cc862553
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index f4527e2477d..7841c86cd9c 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -5568,6 +5568,7 @@ elf_uncompress_lzma_block (const unsigned char 
*compressed,
   uint64_t header_compressed_size;
   uint64_t header_uncompressed_size;
   unsigned char lzma2_properties;
+  size_t crc_offset;
   uint32_t computed_crc;
   uint32_t stream_crc;
   size_t uncompressed_offset;
@@ -5671,19 +5672,20 @@ elf_uncompress_lzma_block (const unsigned char 
*compressed,
   /* The properties describe the dictionary size, but we don't care
  what that is.  */
 
-  /* Block header padding.  */
-  if (unlikely (off + 4 > compressed_size))
+  /* Skip to just before CRC, verifying zero bytes in between.  */
+  crc_offset = block_header_offset + block_header_size - 4;
+  if (unlikely (crc_offset + 4 > compressed_size))
 {
   elf_uncompress_failed ();
   return 0;
 }
-
-  off = (off + 3) &~ (size_t) 3;
-
-  if (unlikely (off + 4 > compressed_size))
+  for (; off < crc_offset; off++)
 {
-  elf_uncompress_failed ();
-  return 0;
+  if (compressed[off] != 0)
+   {
+ elf_uncompress_failed ();
+ return 0;
+   }
 }
 
   /* Block header CRC.  */


libbacktrace patch committed: Link test programs with -no-install

2024-03-02 Thread Ian Lance Taylor
Some of the libbacktrace tests link a program and then modify the
debug info in some way.  When configured with --enable-shared the
linking, using libtool, generates a shell script.  That causes the
tests to fail because they can't modify the debug info of a shell
script.  This patch, originally by Jan Tojnar, pass the -no-install
flag to libtool to avoid generating a shell script.  Bootstrapped and
ran libbacktrace tests on x86_64-pc-linux-gnu.  Committed to mainline.

Ian

* Makefile.am (libbacktrace_testing_ldflags): Define.
(*_LDFLAGS): Add $(libbacktrace_testing_ldflags) for test
programs.
* Makefile.in: Regenerate
9b0d218544cd1b12bf63792c70052d2970acc69b
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 750ed80ed05..5677ecd8865 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -106,6 +106,10 @@ check_DATA =
 # Flags to use when compiling test programs.
 libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
 
+# Flags to use when linking test programs.
+# This avoids generating a shell script when configured with --enable-shared.
+libbacktrace_testing_ldflags = -no-install
+
 if USE_DSYMUTIL
 
 %.dSYM: %
@@ -170,54 +174,63 @@ xcoff_%.c: xcoff.c
 
 test_elf_32_SOURCES = test_format.c testlib.c
 test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_elf_32_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
 
 BUILDTESTS += test_elf_32
 
 test_elf_64_SOURCES = test_format.c testlib.c
 test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_elf_64_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
 
 BUILDTESTS += test_elf_64
 
 test_macho_SOURCES = test_format.c testlib.c
 test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_macho_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_macho_LDADD = libbacktrace_noformat.la macho.lo
 
 BUILDTESTS += test_macho
 
 test_xcoff_32_SOURCES = test_format.c testlib.c
 test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_xcoff_32_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
 
 BUILDTESTS += test_xcoff_32
 
 test_xcoff_64_SOURCES = test_format.c testlib.c
 test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_xcoff_64_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
 
 BUILDTESTS += test_xcoff_64
 
 test_pecoff_SOURCES = test_format.c testlib.c
 test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_pecoff_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
 
 BUILDTESTS += test_pecoff
 
 test_unknown_SOURCES = test_format.c testlib.c
 test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+test_unknown_LDFLAGS = $(libbacktrace_testing_ldflags)
 test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
 
 BUILDTESTS += test_unknown
 
 unittest_SOURCES = unittest.c testlib.c
 unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+unittest_LDFLAGS = $(libbacktrace_testing_ldflags)
 unittest_LDADD = libbacktrace.la
 
 BUILDTESTS += unittest
 
 unittest_alloc_SOURCES = $(unittest_SOURCES)
 unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+unittest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 unittest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += unittest_alloc
@@ -253,7 +266,7 @@ if HAVE_OBJCOPY_DEBUGLINK
 
 b2test_SOURCES = $(btest_SOURCES)
 b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-b2test_LDFLAGS = -Wl,--build-id
+b2test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags)
 b2test_LDADD = libbacktrace_elf_for_test.la
 
 check_PROGRAMS += b2test
@@ -263,7 +276,7 @@ if HAVE_DWZ
 
 b3test_SOURCES = $(btest_SOURCES)
 b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
-b3test_LDFLAGS = -Wl,--build-id
+b3test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags)
 b3test_LDADD = libbacktrace_elf_for_test.la
 
 check_PROGRAMS += b3test
@@ -277,6 +290,7 @@ endif HAVE_ELF
 
 btest_SOURCES = btest.c testlib.c
 btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
+btest_LDFLAGS = $(libbacktrace_testing_ldflags)
 btest_LDADD = libbacktrace.la
 
 BUILDTESTS += btest
@@ -289,6 +303,7 @@ if HAVE_ELF
 
 btest_lto_SOURCES = btest.c testlib.c
 btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto
+btest_lto_LDFLAGS = $(libbacktrace_testing_ldflags)
 btest_lto_LDADD = libbacktrace.la
 
 BUILDTESTS += btest_lto
@@ -297,6 +312,7 @@ endif HAVE_ELF
 
 btest_alloc_SOURCES = $(btest_SOURCES)
 btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+btest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags)
 btest_alloc_LDADD = libbacktrace_alloc.la
 
 BUILDTESTS += btest_alloc
@@ -331,6 +347,7 @@ endif HAVE_DWZ
 
 stest_SOURCES = stest.c
 stest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+stest_LDFLAGS = $(libbacktrace_testing_ldflags)
 stest_LDADD = libbacktrace.la
 
 BUILDTESTS += stest
@@ -341,6 +358,7 @@ endif USE_DSYMUTIL
 
 stest_alloc_SOURCES = $(stest_SOURCES)
 stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
+s

libbacktrace patch committed: Don't assume compressed section aligned

2024-03-08 Thread Ian Lance Taylor
Reportedly when lld compresses debug sections, it fails to set the
alignment of the compressed section such that the compressed header
can be read directly.  To me this seems like a bug in lld.  However,
libbacktrace needs to work around it.  This patch, originally by the
GitHub user ubyte, does that.  Bootstrapped and tested on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

* elf.c (elf_uncompress_chdr): Don't assume compressed section is
aligned.
5825bd0e0d0040126e78269e56c9b9f533e2a520
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 7841c86cd9c..3cd87020b03 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -5076,7 +5076,7 @@ elf_uncompress_chdr (struct backtrace_state *state,
 backtrace_error_callback error_callback, void *data,
 unsigned char **uncompressed, size_t *uncompressed_size)
 {
-  const b_elf_chdr *chdr;
+  b_elf_chdr chdr;
   char *alc;
   size_t alc_len;
   unsigned char *po;
@@ -5088,27 +5088,30 @@ elf_uncompress_chdr (struct backtrace_state *state,
   if (compressed_size < sizeof (b_elf_chdr))
 return 1;
 
-  chdr = (const b_elf_chdr *) compressed;
+  /* The lld linker can misalign a compressed section, so we can't safely read
+ the fields directly as we can for other ELF sections.  See
+ https://github.com/ianlancetaylor/libbacktrace/pull/120.  */
+  memcpy (&chdr, compressed, sizeof (b_elf_chdr));
 
   alc = NULL;
   alc_len = 0;
-  if (*uncompressed != NULL && *uncompressed_size >= chdr->ch_size)
+  if (*uncompressed != NULL && *uncompressed_size >= chdr.ch_size)
 po = *uncompressed;
   else
 {
-  alc_len = chdr->ch_size;
+  alc_len = chdr.ch_size;
   alc = backtrace_alloc (state, alc_len, error_callback, data);
   if (alc == NULL)
return 0;
   po = (unsigned char *) alc;
 }
 
-  switch (chdr->ch_type)
+  switch (chdr.ch_type)
 {
 case ELFCOMPRESS_ZLIB:
   if (!elf_zlib_inflate_and_verify (compressed + sizeof (b_elf_chdr),
compressed_size - sizeof (b_elf_chdr),
-   zdebug_table, po, chdr->ch_size))
+   zdebug_table, po, chdr.ch_size))
goto skip;
   break;
 
@@ -5116,7 +5119,7 @@ elf_uncompress_chdr (struct backtrace_state *state,
   if (!elf_zstd_decompress (compressed + sizeof (b_elf_chdr),
compressed_size - sizeof (b_elf_chdr),
(unsigned char *)zdebug_table, po,
-   chdr->ch_size))
+   chdr.ch_size))
goto skip;
   break;
 
@@ -5126,7 +5129,7 @@ elf_uncompress_chdr (struct backtrace_state *state,
 }
 
   *uncompressed = po;
-  *uncompressed_size = chdr->ch_size;
+  *uncompressed_size = chdr.ch_size;
 
   return 1;
 
@@ -6876,8 +6879,8 @@ elf_add (struct backtrace_state *state, const char 
*filename, int descriptor,
}
 }
 
-  // A debuginfo file may not have a useful .opd section, but we can use the
-  // one from the original executable.
+  /* A debuginfo file may not have a useful .opd section, but we can use the
+ one from the original executable.  */
   if (opd == NULL)
 opd = caller_opd;
 


Re: No rule to make target '../libbacktrace/libbacktrace.la', needed by 'libgo.la'. [PR106472]

2024-03-25 Thread Ian Lance Taylor
On Sat, Mar 23, 2024 at 4:32 AM Дилян Палаузов
 wrote:
>
> Can the build experts say what needs to be changed?  The dependencies I added 
> are missing in the build configuration (@if gcc-bootstrap).
>
> I cannot say if libbacktrace should or should not be a bootstrap=true module.

I don't count as a build expert these days, but since GCC itself links
against libbacktrace, my understanding is that the libbacktrace
host_module should be bootstrap=true, just like, say, libcpp.

Ian


Re: No rule to make target '../libbacktrace/libbacktrace.la', needed by 'libgo.la'. [PR106472]

2024-03-26 Thread Ian Lance Taylor
On Tue, Mar 26, 2024 at 9:33 AM Дилян Палаузов
 wrote:
>
> Makefile.def contains already:
>
> host_modules= { module= libbacktrace; bootstrap=true; }; // since eff02e4f84 
> - "libbacktrace/: * Initial implementation" year 2012
>
> host_modules= { module= libcpp; bootstrap=true; }; // since 4f4e53dd8517c0b2 
> - year 2004

Yes.  I was just trying to answer your question.

Ian

> Am 25. März 2024 23:59:52 UTC schrieb Ian Lance Taylor :
>>
>> On Sat, Mar 23, 2024 at 4:32 AM Дилян Палаузов
>>  wrote:
>>>
>>>
>>>  Can the build experts say what needs to be changed?  The dependencies I 
>>> added are missing in the build configuration (@if gcc-bootstrap).
>>>
>>>  I cannot say if libbacktrace should or should not be a bootstrap=true 
>>> module.
>>
>>
>> I don't count as a build expert these days, but since GCC itself links
>> against libbacktrace, my understanding is that the libbacktrace
>> host_module should be bootstrap=true, just like, say, libcpp.
>>
>> Ian


Go patch committed: initialize local variable in lower_method_expression

2024-03-27 Thread Ian Lance Taylor
This patch to the Go frontend fixes an uninitialized variables in
lower_method_expression.  This fixes GCC PR 114463.  Bootstrapped and
ran Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
7b2a24f3964509bd5b74c4579c7ea5684e82aee1
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 73cb095322c..de6e21fb3b5 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-e15a14e410b8fc5d28012d5b313cb6c8476c7df9
+3f597287b6b858794dabdfe1bf83b386aad18102
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 51ff0206129..8429e553eac 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -9059,7 +9059,7 @@ Selector_expression::lower_method_expression(Gogo* gogo)
 
   Named_type* nt = type->named_type();
   Struct_type* st = type->struct_type();
-  bool is_ambiguous;
+  bool is_ambiguous = false;
   Method* method = NULL;
   if (nt != NULL)
 method = nt->method_function(name, &is_ambiguous);


Go patch committed: Update issue16016 test

2024-03-27 Thread Ian Lance Taylor
This patch to the Go testsuite updates issue16016.go.  This backports
https://go.dev/cl/574536 into the GCC testsuite.  This fixes PR
go/114453.  Bootstrapped and ran test.  Committed to mainline.

Ian
5b6f599670994bef957bd15c683102468a7104f1
diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16016.go 
b/gcc/testsuite/go.test/test/fixedbugs/issue16016.go
index e738e1dba0e..b1947f5548d 100644
--- a/gcc/testsuite/go.test/test/fixedbugs/issue16016.go
+++ b/gcc/testsuite/go.test/test/fixedbugs/issue16016.go
@@ -6,7 +6,10 @@
 
 package main
 
-import "time"
+import (
+   "runtime"
+   "time"
+)
 
 type T struct{}
 
@@ -24,8 +27,19 @@ type Q interface {
 }
 
 func main() {
+   var count = 1
+   if runtime.Compiler == "gccgo" {
+   // On targets without split-stack libgo allocates
+   // a large stack for each goroutine. On 32-bit
+   // systems this test can run out of memory.
+   const intSize = 32 << (^uint(0) >> 63) // 32 or 64
+   if intSize < 64 {
+   count = 100
+   }
+   }
+
var q Q = &R{&T{}}
-   for i := 0; i < 1; i++ {
+   for i := 0; i < count; i++ {
go func() {
defer q.Foo([]interface{}{"meow"})
time.Sleep(100 * time.Millisecond)


Go patch committed: Use correct check for index value overflow

2024-03-27 Thread Ian Lance Taylor
This patch to the Go frontend uses the correct size and comparison
when doing an index value overflow check.  This has apparently been
wrong since I introduced the code ten years ago.  This fixes GCC PR
114500.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
1091113a0036c7315197e09af572dce2beaf1c4c
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index de6e21fb3b5..50d430d5034 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-3f597287b6b858794dabdfe1bf83b386aad18102
+98e92493db2ab7857a5934a950a830fc1f95a4e5
 
 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/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 8429e553eac..238d5a56ca2 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -18790,7 +18790,7 @@ Composite_literal_expression::lower_array(Type* type)
 
  Named_type* ntype = Type::lookup_integer_type("int");
  Integer_type* inttype = ntype->integer_type();
- if (sizeof(index) <= static_cast(inttype->bits() * 8)
+ if (sizeof(index) >= static_cast(inttype->bits() / 8)
  && index >> (inttype->bits() - 1) != 0)
{
  go_error_at(index_expr->location(), "index value overflow");


Re: [PATCH] go: Add go.install-dvi rule in go/Make-lang.in

2024-04-04 Thread Ian Lance Taylor
On Thu, Apr 4, 2024 at 9:27 AM Christophe Lyon
 wrote:
>
> go has a go.dvi build rule, but lacks the go.install-dvi one.
>
> 2024-04-04  Christophe Lyon  
>
> gcc/go/
> * Make-lang.in (go.install-dvi): New rule.

This is OK.  Thanks.

Ian


Go patch committed: Export the type "any" as a builtin

2024-02-02 Thread Ian Lance Taylor
This patch to the Go frontend exports the type "any" as a builtin.
Otherwise we can't tell the difference between builtin type "any" and
a locally defined type "any".

This will require updates to the gccgo export data parsers in the main
Go repo and the x/tools repo.  These updates are https://go.dev/cl/537195
and https://go.dev/cl/537215.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
e52d31804a910642c9817bdd400c290a593c98ef
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index c2a6032ae80..18281c6cd1e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-ddf3758e4a45ca2816fb68f3e4224501a3c4c438
+7ab229670f7dad1d79f33929f9a4f8e6e4a71526
 
 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/export.cc b/gcc/go/gofrontend/export.cc
index 7373deee310..40f6d5d4b2f 100644
--- a/gcc/go/gofrontend/export.cc
+++ b/gcc/go/gofrontend/export.cc
@@ -1661,6 +1661,7 @@ Export::register_builtin_types(Gogo* gogo)
   this->register_builtin_type(gogo, "error", BUILTIN_ERROR);
   this->register_builtin_type(gogo, "byte", BUILTIN_BYTE);
   this->register_builtin_type(gogo, "rune", BUILTIN_RUNE);
+  this->register_builtin_type(gogo, "any", BUILTIN_ANY);
 }
 
 // Register one builtin type in the export table.
diff --git a/gcc/go/gofrontend/export.h b/gcc/go/gofrontend/export.h
index 1f613434cab..be117ece2ce 100644
--- a/gcc/go/gofrontend/export.h
+++ b/gcc/go/gofrontend/export.h
@@ -51,8 +51,9 @@ enum Builtin_code
   BUILTIN_ERROR = -19,
   BUILTIN_BYTE = -20,
   BUILTIN_RUNE = -21,
+  BUILTIN_ANY = -22,
 
-  SMALLEST_BUILTIN_CODE = -21
+  SMALLEST_BUILTIN_CODE = -22
 };
 
 // Export data version number. New export data is written with the
diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc
index 21691fa5ff4..3cc8a720ee4 100644
--- a/gcc/go/gofrontend/import.cc
+++ b/gcc/go/gofrontend/import.cc
@@ -1408,6 +1408,7 @@ Import::register_builtin_types(Gogo* gogo)
   this->register_builtin_type(gogo, "error", BUILTIN_ERROR);
   this->register_builtin_type(gogo, "byte", BUILTIN_BYTE);
   this->register_builtin_type(gogo, "rune", BUILTIN_RUNE);
+  this->register_builtin_type(gogo, "any", BUILTIN_ANY);
 }
 
 // Register a single builtin type.
diff --git a/libgo/go/go/internal/gccgoimporter/parser.go 
b/libgo/go/go/internal/gccgoimporter/parser.go
index 48335fa6d8f..2161df7f368 100644
--- a/libgo/go/go/internal/gccgoimporter/parser.go
+++ b/libgo/go/go/internal/gccgoimporter/parser.go
@@ -187,7 +187,6 @@ func (p *parser) parseQualifiedNameStr(unquotedName string) 
(pkgpath, name strin
 // getPkg returns the package for a given path. If the package is
 // not found but we have a package name, create the package and
 // add it to the p.imports map.
-//
 func (p *parser) getPkg(pkgpath, name string) *types.Package {
// package unsafe is not in the imports map - handle explicitly
if pkgpath == "unsafe" {
@@ -904,6 +903,7 @@ const (
gccgoBuiltinERROR  = 19
gccgoBuiltinBYTE   = 20
gccgoBuiltinRUNE   = 21
+   gccgoBuiltinANY= 22
 )
 
 func lookupBuiltinType(typ int) types.Type {
@@ -928,13 +928,13 @@ func lookupBuiltinType(typ int) types.Type {
gccgoBuiltinERROR:  types.Universe.Lookup("error").Type(),
gccgoBuiltinBYTE:   types.Universe.Lookup("byte").Type(),
gccgoBuiltinRUNE:   types.Universe.Lookup("rune").Type(),
+   gccgoBuiltinANY:types.Universe.Lookup("any").Type(),
}[typ]
 }
 
 // Type = "<" "type" ( "-" int | int [ TypeSpec ] ) ">" .
 //
 // parseType updates the type map to t for all type numbers n.
-//
 func (p *parser) parseType(pkg *types.Package, n ...any) types.Type {
p.expect('<')
t, _ := p.parseTypeAfterAngle(pkg, n...)
@@ -1117,9 +1117,10 @@ func (p *parser) maybeCreatePackage() {
 }
 
 // InitDataDirective = ( "v1" | "v2" | "v3" ) ";" |
-// "priority" int ";" |
-// "init" { PackageInit } ";" |
-// "checksum" unquotedString ";" .
+//
+// "priority" int ";" |
+// "init" { PackageInit } ";" |
+// "checksum" unquotedString ";" .
 func (p *parser) parseInitDataDirective() {
if p.tok != scanner.Ident {
// unexpected token kind; panic
@@ -1170,15 +1171,16 @@ func (p *parser) parseInitDataDirective() {
 }
 
 // Directive = InitDataDirective |
-// "package" unquotedString [ unquotedString ] [ unquotedString ] 
";" |
-// "pkgpath" unquotedString ";" |
-// "prefix" unquotedString ";" |
-// "import" unquotedString unquotedString string ";" |
-// "indirectimport" unquotedString unquotedstring ";" |
-// "func" Func ";" |
-// "type" Type ";" |
-// "var" Var ";" |
-// "const" Const

libgo patch committed: Better error messages for unsupported target

2024-02-02 Thread Ian Lance Taylor
This libgo patch generates better error messages then the Go GOARCH
and GOOS values can't be determined from the target.  This indicates
that the target is not supported.  This is for GCC PR 113530.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
cfc6d9ae8143cf0e903384bc63e8d659ca1c9fe7
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 18281c6cd1e..429904a2b8f 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-7ab229670f7dad1d79f33929f9a4f8e6e4a71526
+8c056e335cecec67d1d223a329b7ba4dac778a65
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index c95dc2106cd..3eccadbac67 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -497,6 +497,10 @@ s-version: Makefile
 zgoarch.go: s-zgoarch; @true
 s-zgoarch: Makefile goarch.sh
rm -f zgoarch.go.tmp
+   if ! $(SHELL) $(srcdir)/goarch.sh $(GOARCH) family >/dev/null 
2>/dev/null;  then \
+ $(SHELL) $(srcdir)/goarch.sh $(GOARCH) family; \
+ exit 1; \
+   fi
echo "package goarch" > zgoarch.go.tmp
echo >> zgoarch.go.tmp
echo 'const GOARCH = "'$(GOARCH)'"' >> zgoarch.go.tmp
diff --git a/libgo/configure.ac b/libgo/configure.ac
index e8d66f8415d..22158ac7f5d 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -209,6 +209,10 @@ AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o 
$is_dragonfly = yes -o $is
 AC_SUBST(GOOS)
 AC_SUBST(ALLGOOS)
 
+if test "${GOOS}" = "unknown"; then
+   AC_MSG_ERROR("could not determine GOOS from ${host}")
+fi
+
 dnl Test whether we need to use DejaGNU or whether we can use the
 dnl simpler gotest approach.  We can only use gotest for a native
 dnl build.
@@ -376,6 +380,10 @@ AC_SUBST(GOARCH)
 AC_SUBST(ALLGOARCH)
 AC_SUBST(ALLGOARCHFAMILY)
 
+if test "${GOARCH}" = "unknown"; then
+   AC_MSG_ERROR("could not determine GOARCH from ${host}")
+fi
+
 AM_CONDITIONAL(LIBGO_IS_X86, test "$GOARCH" = "386" -o "$GOARCH" = "amd64" -o 
"$GOARCH" = "amd64p32")
 
 FUNCTION_DESCRIPTORS=false


  1   2   3   4   5   6   7   8   9   10   >