Commit Graph

1064 Commits

Author SHA1 Message Date
Ian Lance Taylor db03bf50fc re PR go/79642 (space instead of tab in lang.opt)
PR go/79642
	* lang.opt (-fgo-relative-import-path): Change space to tab.

From-SVN: r245619
2017-02-21 00:23:52 +00:00
Ian Lance Taylor 00b2a30fd4 libgo: update to final Go 1.8 release
Along with the update this fixes a problem that was always present but
    only showed up with the new reflect test.  When a program used a
    **unsafe.Pointer and stored the value in an interface type, the
    generated type descriptor pointed to the GC data for *unsafe.Pointer.
    It did that by name, but we were not generating a variable with the
    right name.
    
    Reviewed-on: https://go-review.googlesource.com/37144

From-SVN: r245535
2017-02-17 15:43:39 +00:00
Ian Lance Taylor 7953a24c60 re PR go/79443 (libgo/math test fails on s390x (undefined symbols cosh, sinh, tanh, hasVX))
PR go/79443
    libgo: fix some s390x tests
    
    Add `+build ignore` to ignore tests that rely on s390x assembly code
    not yet implemented for gccgo.
    
    Fixes GCC PR 79443.
    
    Reviewed-on: https://go-review.googlesource.com/36909

From-SVN: r245397
2017-02-13 17:37:02 +00:00
Richard Biener a4cf4b647c re PR tree-optimization/79256 (FAIL: gcc.dg/vect/pr25413a.c execution test)
2017-02-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/79256
	PR middle-end/79278
	* builtins.c (get_object_alignment_2): Use min_align_of_type
	to extract alignment for MEM_REFs to honor BIGGEST_FIELD_ALIGNMENT
	and ADJUST_FIELD_ALIGN.

	* doc/tm.texi.in (ADJUST_FIELD_ALIGN): Adjust to take additional
	type parameter.
	* doc/tm.texi: Regenerate.
	* stor-layout.c (layout_decl): Adjust.
	(update_alignment_for_field): Likewise.
	(place_field): Likewise.
	(min_align_of_type): Likewise.
	* config/arc/arc.h (ADJUST_FIELD_ALIGN): Adjust.
	* config/epiphany/epiphany.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/epiphany/epiphany.c (epiphany_adjust_field_align): Likewise.
	* config/frv/frv.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/frv/frv.c (frv_adjust_field_align): Likewise.
	* config/i386/i386.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/i386/i386.c (x86_field_alignment): Likewise.
	* config/rs6000/aix.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/rs6000/darwin.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/rs6000/freebsd64.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/rs6000/linux64.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/rs6000/sysv4.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/rs6000/rs6000.c (rs6000_special_adjust_field_align_p):
	 Likewise.

	go/
	* go-backend.c (go_field_alignment): Adjust.

	libobjc/
	* encoding.c (objc_layout_structure_next_member): Adjust
	ADJUST_FIELD_ALIGN usage.

	Revert
	2017-01-30  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/79256
	* targhooks.c (default_builtin_vector_alignment_reachable): Honor
	BIGGEST_FIELD_ALIGNMENT and ADJUST_FIELD_ALIGN to fix up bogus
	alignment on TYPE.

From-SVN: r245245
2017-02-07 11:29:06 +00:00
Ian Lance Taylor 46f7b80ec4 compiler: let initializers hold addresses of fields
The runtime.dbgvars initializer looks like
    
    var dbgvars = []dbgVar{
            {"allocfreetrace", &debug.allocfreetrace},
    }
    
    Because the field address was not recognized as valid for a static
    initializer, the variable was initialized at runtime.  Normally that
    would be fine, but for the runtime package it meant that dbgvars was
    not initialized when it was read by parsedebugvars.  That meant that
    the GODEBUG environment variable did nothing.
    
    Fixing that revealed that the static initializer checks had to be more
    careful about interface types, just like the existing is_constant
    methods.
    
    Reviewed-on: https://go-review.googlesource.com/35891

From-SVN: r244982
2017-01-27 15:08:23 +00:00
Ian Lance Taylor 41d3d0ac40 runtime: fix setting of isarchive
When I updated to Go 1.8, the initsig function moved from
    signal1_unix.go to signal_unix.go, and lost a gccgo-specific change in
    the move.  Add it back.
    
    This would have been caught by the misc/cgo/testcarchive tests in the
    gc repository, but we don't run those in the gccgo repository.  We
    should fix that, somehow.
    
    Reviewed-on: https://go-review.googlesource.com/35839

From-SVN: r244947
2017-01-26 19:07:54 +00:00
Ian Lance Taylor fda6ee7033 runtime: fix context used by getTraceback
I typoed the argument passed to getcontext in getTraceback, and the
    error was hidden by ucontext_arg.  This would have been caught by some
    of the runtime package tests, but we don't run most of them because
    they rely on `go build`, and the go tool is not available while
    running the libgo testsuite.  We should fix the libgo testsuite,
    somehow, so that they run.
    
    Reviewed-on: https://go-review.googlesource.com/35837

From-SVN: r244946
2017-01-26 19:05:16 +00:00
Ian Lance Taylor 98e2075846 compiler: improvements for type alias handling
Give an error for an attempt to define a method on an imported type.
    
    Give an error for each attempt to define a method on a builtin type.
    
    Adjust error messages to be closer to gc error messages.
    
    With these changes gccgo passes current tests on dev.typealias branch.
    
    This changes the errors printed for test/fixedbugs/issue5089.go, but
    the change is an improvement:
    
        Before:
            fixedbugs/issue5089.go:13:1: error: redefinition of ‘bufio.Buffered’: receiver name changed
             func (b *bufio.Reader) Buffered() int { // ERROR "non-local|redefinition"
             ^
            fixedbugs/issue5089.go:11:13: note: previous definition of ‘bufio.Buffered’ was here
             import "bufio" // GCCGO_ERROR "previous"
                         ^
    
        Now:
            fixedbugs/issue5089.go:13:7: error: may not define methods on non-local type
             func (b *bufio.Reader) Buffered() int { // ERROR "non-local|redefinition"
                   ^
    
    Reviewed-on: https://go-review.googlesource.com/35642

From-SVN: r244889
2017-01-25 05:12:26 +00:00
Ian Lance Taylor c25edd44a0 libgo: update to go1.8rc2
Fix a bug in the generation of the hash value in reflect.FuncOf.
    
    The merge script missed a bunch of testdata files over the years.
    Copy them over.
    
    Reviewed-on: https://go-review.googlesource.com/35570

From-SVN: r244835
2017-01-23 22:18:42 +00:00
Ian Lance Taylor b0147ac2e6 re PR go/79037 (gccgo: Binaries crash with parforsetup: pos is not aligned on m68k)
PR go/79037
    compiler, runtime: align gc data for m68k
    
    The current GC requires that the gc data be aligned to at least a 4
    byte boundary, because it uses the lower two bits of the address for
    flags (see LOOP and PRECISE in runtime/mgc0.c).  As the gc data is
    stored as a [...]uintptr, that is normally always true.  However, on
    m68k, that only guarantees 2 byte alignment.  Fix it by forcing the
    alignment.
    
    The parfor code used by the current GC requires that the parfor data
    be aligned to at least an 8 byte boundary.  The code in parfor.c
    verifies this.  This is normally true, as the data uses uint64_t
    values, but, again, this must be enforced explicitly on m68k.
    
    Fixes GCC PR 79037.
    
    Reviewed-on: https://go-review.googlesource.com/35478

From-SVN: r244824
2017-01-23 18:15:22 +00:00
Ian Lance Taylor a0488df436 libgo: bump library version to 11
As usual I forgot to bump the library version when I updated the
    library to 1.8rc1.
    
    Reviewed-on: https://go-review.googlesource.com/35568

From-SVN: r244823
2017-01-23 18:10:13 +00:00
Ian Lance Taylor 4a5b806048 runtime, testing/internal/testdeps: fixes for cgo
Some fixes that permit misc/cgo/test in the master gc repository to
    pass using the current gccgo.
    
    Install testing/internal/testdeps.gox; it is needed by `go test`.
    
    Export runtime.lockedOSThread to enable calling via go:linkname; it is
    used by misc/cgo/test.
    
    Loop on EAGAIN when creating a new thread; this is what the gc code
    does, and misc/cgo/test tests that it works.
    
    Reviewed-on: https://go-review.googlesource.com/35479

From-SVN: r244733
2017-01-20 21:18:37 +00:00
Ian Lance Taylor 5dc8f5d9e6 re PR go/79146 (Bootstrapping go on s390x fails; redefined symbols)
PR go/79146
    math/big: fix build on s390x
    
    Don't build arith_decl_s390x.go for gccgo; it is only for assembly
    code that has not yet been ported to gccgo.
    
    For GCC PR 79146.

From-SVN: r244731
2017-01-20 20:39:10 +00:00
Ian Lance Taylor 198766b648 re PR go/79146 (Bootstrapping go on s390x fails; redefined symbols)
PR go/79146
    crypto/elliptic: explicitly ignore p256_s390x.go
    
    The file only works if used in conjunction with assembly code not
    (yet) written for gccgo.
    
    Fixes GCC PR 79146.

    Reviewed-on: https://go-review.googlesource.com/35477

From-SVN: r244679
2017-01-20 02:27:46 +00:00
Ian Lance Taylor 49947b33ff syscall, golang_org/x/net/lif: fixes for gccgo on Solaris
Reviewed-on: https://go-review.googlesource.com/35390

From-SVN: r244563
2017-01-18 03:37:52 +00:00
Ian Lance Taylor a2a7ea4834 runtime: rename siginfo to _siginfo_t
Since the name siginfo winds up in runtime.inc, this avoids a name
    collision on systems that define "struct siginfo" in the system header
    files.
    
    Reviewed-on: https://go-review.googlesource.com/35239

From-SVN: r244484
2017-01-16 01:21:42 +00:00
Ian Lance Taylor 58a3a26bbd libgo: correct golang_org Makefile variables not used on all systems
Patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/35238

From-SVN: r244483
2017-01-16 01:05:10 +00:00
Ian Lance Taylor a2bd02aecf compiler: implement type aliases
This is a start of implementing type aliases (`type T1 = T2`) in the
    Go frontend.  This is incomplete, in that the reflection information
    is not updated for an embedded type alias.  It is also not well
    tested.  Finally, the change to the language has not been approved.
    This should be regarded as preliminary work for experimental use.
    
    Update golang/go#18130.
    
    Reviewed-on: https://go-review.googlesource.com/35120

From-SVN: r244460
2017-01-14 01:50:31 +00:00
Ian Lance Taylor c2047754c3 libgo: update to Go 1.8 release candidate 1
Compiler changes:
      * Change map assignment to use mapassign and assign value directly.
      * Change string iteration to use decoderune, faster for ASCII strings.
      * Change makeslice to take int, and use makeslice64 for larger values.
      * Add new noverflow field to hmap struct used for maps.
    
    Unresolved problems, to be fixed later:
      * Commented out test in go/types/sizes_test.go that doesn't compile.
      * Commented out reflect.TestStructOf test for padding after zero-sized field.
    
    Reviewed-on: https://go-review.googlesource.com/35231

gotools/:
	Updates for Go 1.8rc1.
	* Makefile.am (go_cmd_go_files): Add bug.go.
	(s-zdefaultcc): Write defaultPkgConfig.
	* Makefile.in: Rebuild.

From-SVN: r244456
2017-01-14 00:05:42 +00:00
Than McIntosh a2182c9cc2 compiler: add containing Bfunction to conditional_expression
Add containing Bfunction to Backend::conditional_expression
    method signature, since the back end might need to create a
    temporary when generating IR for this construct.
    
    Reviewed-on: https://go-review.googlesource.com/35056

From-SVN: r244330
2017-01-11 18:15:16 +00:00
Ian Lance Taylor 25e15acf8c compiler: mark generated struct/array types as incomparable
The recent change to generate type functions for more types with
    identity comparisons caused us to generate some unnecessary functions,
    and even caused a compiler crash on Solaris due to phase ordering.
    Avoid this by marking all generated and uncompared struct and array
    types as incomparable, so that we don't try to generate type functions
    for them.
    
    Reviewed-on: https://go-review.googlesource.com/35110

From-SVN: r244327
2017-01-11 17:41:49 +00:00
Ian Lance Taylor 6fcb740ac4 runtime: copy more scheduler code from Go 1.7 runtime
I looked at a diff of proc.go between Go 1.7 and gccgo, and copied
    over all the easy stuff.
    
    Reviewed-on: https://go-review.googlesource.com/35090

From-SVN: r244291
2017-01-10 21:09:00 +00:00
Ian Lance Taylor 0c22e4415f compiler, runtime: drop size arguments to hash/equal functions
Drop the size arguments for the hash/equal functions stored in type
    descriptors.  Types know what size they are.  To make this work,
    generate hash/equal functions for types that can use an identity
    comparison but are not a standard size and alignment.
    
    Drop the multiplications by 33 in the generated hash code and the
    reflect package hash code.  They are not necessary since we started
    passing a seed value around, as the seed includes the hash of the
    earlier values.
    
    Copy the algorithms for standard types from the Go 1.7 runtime,
    replacing the C functions.
    
    Reviewed-on: https://go-review.googlesource.com/34983

From-SVN: r244256
2017-01-10 03:59:20 +00:00
Ian Lance Taylor 2193ad7fbf runtime: copy more of scheduler from Go 1.7 runtime
This started by moving procresize from C to Go so that we can pass the
    right type to the memory allocator when allocating a p, which forced
    the gomaxprocs variable to move from C to Go, and everything else
    followed from that.
    
    Reviewed-on: https://go-review.googlesource.com/34916

From-SVN: r244236
2017-01-09 19:37:19 +00:00
Ian Lance Taylor 08934aed39 re PR go/78978 (runtime/pprof FAILs on Solaris 2/x86)
PR go/78978
    libgo: build with -Wa,-nH if possible on Solaris
    
    By default the Solaris assembler records the required hardware
    capability in the object file.  This means that the AES hashing code
    breaks on systems that do not support AES, even though the code uses a
    runtime check to only actually invoke the AES instructions on systems
    that support it.  An earlier fix for the problem only fixed the shared
    library, not the static libgo.a.  Fix the problem for real by using an
    assembler option to not record the hardware capability.
    
    For GCC PR 78978.
    
    Patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/34910

From-SVN: r244165
2017-01-06 16:04:01 +00:00
Ian Lance Taylor 0f2a6e84c6 runtime: remove __go_alloc and __go_free
Move allocg and handling of allgs slice from C to Go.
    
    Reviewed-on: https://go-review.googlesource.com/34797

From-SVN: r244036
2017-01-03 22:58:48 +00:00
Ian Lance Taylor b379f8d81f re PR go/78789 (Error: no such instruction: `aesenc %xmm0,%xmm2' when compiling libgo/runtime/aeshash.c)
PR go/78789
    runtime: don't build aeshash.c if the assembler doesn't support it
    
    This is for CentOS 5, whose assembler does not know the aesinc
    instruction.
    
    Fixes GCC PR 78789.
    
    Patch by Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/34796

From-SVN: r244031
2017-01-03 20:41:54 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek c1a9c36961 gcc.c (process_command): Update copyright notice dates.
gcc/
	* gcc.c (process_command): Update copyright notice dates.
	* gcov-dump.c (print_version): Ditto.
	* gcov.c (print_version): Ditto.
	* gcov-tool.c (print_version): Ditto.
	* gengtype.c (create_file): Ditto.
	* doc/cpp.texi: Bump @copying's copyright year.
	* doc/cppinternals.texi: Ditto.
	* doc/gcc.texi: Ditto.
	* doc/gccint.texi: Ditto.
	* doc/gcov.texi: Ditto.
	* doc/install.texi: Ditto.
	* doc/invoke.texi: Ditto.
gcc/fortran/
	* gfortranspec.c (lang_specific_driver): Update copyright notice
	dates.
	* gfc-internals.texi: Bump @copying's copyright year.
	* gfortran.texi: Ditto.
	* intrinsic.texi: Ditto.
	* invoke.texi: Ditto.
gcc/ada/
	* gnat_ugn.texi: Bump @copying's copyright year.
	* gnat_rm.texi: Likewise.
gcc/go/
	* gccgo.texi: Bump @copyrights-go year.
libitm/
	* libitm.texi: Bump @copying's copyright year.
libgomp/
	* libgomp.texi: Bump @copying's copyright year.
libquadmath/
	* libquadmath.texi: Bump @copying's copyright year.

From-SVN: r243992
2017-01-01 12:31:28 +01:00
Ian Lance Taylor 7d5c50520a compile: add type conversion in Type::gc_symbol_pointer
Wrap the return from Type::gc_symbol_pointer with a type conversion to
    uintptr, since the values returned are stored into structure fields
    with that type.
    
    Reviewed-on: https://go-review.googlesource.com/34625

From-SVN: r243978
2016-12-30 18:03:39 +00:00
Ian Lance Taylor 270ca283ff compiler: use more accurate array type in Gogo::register_gc_vars
The length of the roots array in Gogo::register_gc_vars was being
    computed incorrectly, potentially leading to type clashes in the back
    end. Compute an accurate length for this array ahead of time.
    
    Reviewed-on: https://go-review.googlesource.com/34624

From-SVN: r243974
2016-12-30 07:08:00 +00:00
Ian Lance Taylor 28171b9d5d compiler: fix spurious redefinition error for anon struct
Change Struct_type::do_mangled_name to incorporate the field
    names even for hidden symbols. This is needed in cases where
    a package imports a type "S" that has an anonymous struct, e.g.
    
      // imported from some other package
      type S struct {
        X struct{ _ struct{} }
      }
    
    and then defines a local type that uses a structurally identical
    anonymous struct, e.g.
    
      // defined locally
      type T struct {
        U struct{ _ struct{} }
      }
    
    In the case above both types triggered the creation of hash/equal
    methods, but the method names were clashing (since both structs
    had the same mangled name).
    
    Fixes golang/go#18414
    
    Reviewed-on: https://go-review.googlesource.com/34621

From-SVN: r243899
2016-12-22 23:05:02 +00:00
Ian Lance Taylor 0d3dd8fb65 runtime: copy cgo support from Go 1.7 runtime
Remove support for _cgo_allocate.  It was removed from the gc
    toolchain in Go 1.5, so it is unlikely that anybody is trying to use it.
    
    Reviewed-on: https://go-review.googlesource.com/34557

From-SVN: r243805
2016-12-19 18:00:35 +00:00
Than McIntosh 8220e3f9bd compiler: add containing Bfunction to some backend interfaces.
Change the interfaces for backend methods that create statements to
    always pass in the enclosing Bfunction for the statement.  Having the
    function available simplifies things if a temporary variable has to be
    created during the construction of a statement.
    
    This also includes a change to the Mark_lvalue_varexprs helper
    class to handle indirections on the left hand side of assignments
    (e.g. "*x.y = ...").
    
    Reviewed-on: https://go-review.googlesource.com/34471

	* go-gcc.cc (Gcc_backend::expression_statement): Add Bfunction*
	parameter.
	(Gcc_backend::init_statement): Likewise.
	(Gcc_backend::assignment_statement): Likewise.
	(Gcc_backend::if_statement): Likewise.

From-SVN: r243766
2016-12-16 22:11:28 +00:00
Ian Lance Taylor 2ae30b147b compiler: fix comments + fieldnames to match libgo source
A couple of the comments in the type descriptor code were out of date
    with respect to the names in libgo/go/runtime/type.go.  Fix up the
    comments and field names to bring them into sync.
    
    Reviewed-on: https://go-review.googlesource.com/34472

From-SVN: r243735
2016-12-16 00:34:37 +00:00
Ian Lance Taylor 63ba3ad3ed compiler: fix off-by-1 array type len in Type::gc_symbol_constructor
Array type being built to hold GC var initializer was being created
    with an extra/unneeded slot. Fix up the code to insure that the array
    length matches the length of the initializer list.
    
    Reviewed-on: https://go-review.googlesource.com/34413

From-SVN: r243731
2016-12-15 23:44:13 +00:00
Ian Lance Taylor 62afb87d9c re PR go/78763 (go1: internal compiler error: in do_get_backend, at go/gofrontend/expressions.cc:8352)
PR go/78763
    compiler: call determine_types even for constant expressions
    
    We need to call determine_types even for constant expressions, since a
    constant expression may include code like unsafe.Sizeof(0).  Something
    needs to determine the type of the untyped 0, and that should be the
    determine_types pass.
    
    Implementing that triggered a compiler crash on test/const1.go because
    it permitted some erroneous constants to make it all the way to the
    backend.  Catch that case by checking whether we get a constant
    overflow error, and marking the expression invalid if we do.  This is
    a good change in any case, as previously we reported the same constant
    overflow error multiple times, and now we only report it once.
    
    Fixes GCC PR 78763.
    
    Reviewed-on: https://go-review.googlesource.com/34496

From-SVN: r243729
2016-12-15 22:47:43 +00:00
Ian Lance Taylor edda2869d0 compiler: remove unneeded zero-length slice value init
Prune away a bit of unnecessary code from the helper routine
    Slice_construction_expression::create_array_val() that was adding
    an extra NULL value to empty slices (no longer needed).
    
    Reviewed-on: https://go-review.googlesource.com/34410

From-SVN: r243682
2016-12-15 02:14:40 +00:00
Ian Lance Taylor c3c54e0f07 libgo: fixes for Solaris build
Don't put m[0-4] in runtime.inc.
    
    Pass -mclear-hwcap to the linker if supported.
    
    From Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/34331

From-SVN: r243619
2016-12-13 18:03:45 +00:00
Ian Lance Taylor 560bcfdcfd runtime: mark non-x86 aeshashbody parameters as unused
Avoids warnings during the build.
    
    Reviewed-on: https://go-review.googlesource.com/34142

From-SVN: r243459
2016-12-08 20:43:19 +00:00
Ian Lance Taylor 453060a906 runtime: copy memory hash code from Go 1.7
Rewrite the AES hashing code from gc assembler to C code using
    intrinsics.  The resulting code generates the same hash code for the
    same input as the gc code--that doesn't matter as such, but testing it
    ensures that the C code does something useful.
    
    Also change mips64pe32le to mips64p32le in configure script--noticed
    during CL review.
    
    Reviewed-on: https://go-review.googlesource.com/34022

From-SVN: r243445
2016-12-08 16:37:54 +00:00
Ian Lance Taylor b2264b0964 runtime: allocate _panic struct on heap
The gc library allocates a _panic struct on the stack. This does not
    work for gccgo, because when a deferred function recovers the panic we
    unwind the stack up to that point so that returning from the function
    will work correctly.
    
    Allocating on the stack fine if the panic is not recovered, and it
    works fine if the panic is recovered by a function that
    returns. However, it fails if the panic is recovered by a function
    that itself panics, and if that second panic is then recovered by a
    function higher up on the stack. When we unwind the stack to that
    second panic, the g will wind up pointing at a panic farther down on
    the stack. Even then everything will often work fine, except when the
    deferred function catching the second panic makes a bunch of calls
    that use stack space before returning. In that case the code can
    overwrite the panic struct, which will then cause disaster when we
    remove the struct from the linked list, as the link field will be
    garbage. This case is rare enough that all the x86 tests were passing,
    but there was a failure on ppc64le.
    
    Before https://golang.org/cl/33414 we allocated the panic struct on
    the heap, so go back to doing that again.
    
    Fixes golang/go#18228.
    
    Reviewed-on: https://go-review.googlesource.com/34027

From-SVN: r243444
2016-12-08 15:54:30 +00:00
Ian Lance Taylor 55dccc1e0d compiler: make Slice_construction_expression::do_flatten idempotent
Because of the way we handle call expressions with multiple results,
    it's possible for expressions to be flattened more than once.  In the
    case of Slice_construction_expression, allocating the slice storage
    multiple times caused a compiler crash as one of the
    Temporary_statement's wound up not getting a backend expression.
    
    Test case is https://golang.org/cl/34020.
    
    Reviewed-on: https://go-review.googlesource.com/34026

From-SVN: r243442
2016-12-08 15:51:25 +00:00
Ian Lance Taylor 776a8a927e runtime: remove some unused variables/declarations from runtime.h
Small patch from Eric Botcazou.
    
    Reviewed-on: https://go-review.googlesource.com/34029

From-SVN: r243424
2016-12-08 00:38:03 +00:00
Than McIntosh a5a56d88a1 compiler: pass lvalue/rvalue context to back end for var exprs
Add a new flag on the Var_expression class that indicates
    whether the var reference appears in an "lvalue" context
    (for example, on the LHS of an assignment stmt) or an
    "rvalue" context (for example, as an argument of a call).
    
    Add a traversal pass that visits assignment stmt LHS subtrees
    so as to mark things prior to backend gen. Select the right
    context value in other places where Backend::var_expression is
    called.
    
    Reviewed-on: https://go-review.googlesource.com/33990

	* go-gcc.cc (Gcc_backend::var_expression): Add Varexpr_context
	parameter.

From-SVN: r243321
2016-12-06 22:31:25 +00:00
Ian Lance Taylor 98934fac3b compiler: add slice initializers to the GC root list
As of https://golang.org/cl/32917 we can put slice initializers in the
    .data section.  The program can still change the values in those
    slices.  That means that if the slice elements can contain pointers,
    we need to register the entire initializer as a GC root.
    
    This would be straightforward except that we only have a Bexpression
    for the slice initializer, not an Expression.  So introduce a
    Backend_expression type that wraps a Bexpression as an Expression.
    
    The test case for this is https://golang.org/cl/33790.
    
    Reviewed-on: https://go-review.googlesource.com/33792

From-SVN: r243129
2016-12-01 19:54:36 +00:00
Ian Lance Taylor 6e7f1be7ae runtime: set isarchive in initsig
The library initialization code in go-libmain.c sets the C variable
    runtime_isarchive but failed to set the Go variable runtime.isarchive.
    We don't currently have a way to let C code access an unexported Go
    variable, but fortunately the only time the Go function initsig is
    called with an argument of true is exactly where we want to set
    isarchive.  So let initsig do it.
    
    Reviewed-on: https://go-review.googlesource.com/33753

From-SVN: r243094
2016-12-01 05:47:58 +00:00
Ian Lance Taylor 24f1d7f80e runtime: print C functions in traceback
Since gccgo can trace back through C code as easily as Go code, we
    should print C functions in the traceback.
    
    This worked before https://golang.org/cl/31230 for a dumb reason.  The
    default value for runtime.traceback_cache was, and is, 2 << 2, meaning
    to print all functions.  The old C code for runtime_parsedebugvars
    would return immediately and do nothing if the environment variable
    GODEBUG was not set (if GODEBUG was set it would later call
    setTraceback.  The new Go code for runtime.parsedebugvars does not
    return immediately if GODEBUG is not set, and always calls
    setTraceback.  Either way, if GOTRACEBACK is not set, setTraceback
    would set traceback_cache to 1 << 2, meaning to only print non-runtime
    functions and having the effect of not printing plain C functions.
    
    Keep the current handling of GODEBUG/GOTRACEBACK, which matches the gc
    library, but add an extra check to print C functions by default.
    
    Reviewed-on: https://go-review.googlesource.com/33717

From-SVN: r243083
2016-11-30 20:28:28 +00:00
Ian Lance Taylor fbe9724cc3 runtime: fixes for -buildmode=c-archive
With -buildmode=c-archive, initsig is called before the memory
    allocator has been initialized.  The code was doing a memory
    allocation because of the call to funcPC(sigtramp).  When escape
    analysis is fully implemented, that call should not allocate.  For
    now, finesse the issue by calling a C function to get the C function
    pointer value of sigtramp.
    
    When returning from a call from C to a Go function, a deferred
    function is run to go back to syscall mode.  When the call occurs on a
    non-Go thread, that call sets g to nil, making it impossible to add
    the _defer struct back to the pool.  Just drop it and let the garbage
    collector clean it up.
    
    Reviewed-on: https://go-review.googlesource.com/33675

From-SVN: r242992
2016-11-30 02:09:24 +00:00
Than McIntosh f3878205dd compiler: relocate ID encoding utilities to gofrontend
Relocate the code that encodes/sanitizes identifiers to make them
    assembler-friendly, moving it from the back end to the front end; the
    decisions about when to encode an identifier and the calls to the
    encoding helpers now take place entirely in gofrontend.
    
    Reviewed-on: https://go-review.googlesource.com/33424

	* go-gcc.cc (char_needs_encoding): Remove.
	(needs_encoding, fetch_utf8_char, encode_id): Remove.
	(Gcc_backend::global_variable): Add asm_name parameter.  Don't
	compute asm_name here.
	(Gcc_backend::implicit_variable): Likewise.
	(Gcc_backend::implicit_variable_reference): Likewise.
	(Gcc_backend::immutable_struct): Likewise.
	(Gcc_backend::immutable_struct_reference): Likewise.
	* Make-lang.in (GO_OBJS): Add go/go-encode-id.o.

From-SVN: r242726
2016-11-22 22:28:05 +00:00