Go patch committed: Work around warning to fix bootstrap

2024-11-29 Thread Ian Lance Taylor
This patch to the Go frontend increases the size of a temporary buffer to avoid a new warning. The warning was breaking bootstrapping with Go. GCC has a new -Wformat-truncation warning that triggers on some Go frontend code: ../../gcc/go/gofrontend/go-encode-id.cc: In function 'std::string go_en

Go patch committed: Don't assume that ATTRIBUTE_UNUSED is defined

2024-08-07 Thread Ian Lance Taylor
This patch to the Go frontend avoids assuming that ATTRIBUTE_UNUSED is defined. While it is defined when building the Go frontend as part of GCC, it is meant to work with other compilers as well. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian e89ddb749517ea

Go patch committed: Panic arguments have empty interface type

2024-08-05 Thread Ian Lance Taylor
This patch to the Go frontend determines that panic arguments are empty interfaces. After https://go.dev/cl//536643 passing NULL as the expected type permitted an untyped constant expression to remain untyped. This change will fix them to take on the empty interface type. The panic and print/prin

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 1

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/issue1

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/gofron

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.

Go patch committed: Don't pass iota value to lowering pass

2024-01-22 Thread Ian Lance Taylor
This patch to the Go frontend stops passing the iota value to the lowering pass. It is no longer used. The iota value is now handled in the determine-types pass. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 896148947b9ff4845c8bc334f8eff30f91ff3c9a diff -

Re: Go patch committed: Move lowering pass after check types pass

2024-01-18 Thread Ian Lance Taylor
On Mon, Dec 18, 2023 at 5:32 PM Ian Lance Taylor wrote: > > This Go frontend patch moves the lowering pass after the type > determination and the type checking passes. This lets us simplify > some of the code that determines the type of an expression, which > previously had to work correctly both

Go patch committed: Move lowering pass after check types pass

2023-12-18 Thread Ian Lance Taylor
This Go frontend patch moves the lowering pass after the type determination and the type checking passes. This lets us simplify some of the code that determines the type of an expression, which previously had to work correctly both before and after type determination. I'm doing this to help with

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 a

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

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. Ia

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

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/MER

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/gofr

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

Go patch committed: Support -fgo-importcfg

2023-06-26 Thread Ian Lance Taylor via Gcc-patches
The gc Go compiler has a -importcfg option that takes a file that provides a mapping from import paths to the files that satisfy those imports. This is used by the go build tool to let the compiler read imported packages directly out of the build cache. Without this option the go build tool has t

Go patch committed: Support bootstrapping Go 1.21

2023-06-23 Thread Ian Lance Taylor via Gcc-patches
compiler, libgo: support bootstrapping gc compiler In the Go 1.21 release the package internal/profile imports internal/lazyregexp. That works when bootstrapping with Go 1.17, because that compiler has internal/lazyregep and permits importing it. We also have internal/lazyregexp in libgo, but sin

Go patch committed: Determine types of Slice_{value, info} expressions

2023-06-21 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend determines the types of a couple of expressions types that accidentally failed to recurse into their subexpressions. The test case for this is https://go.dev/cl/505015. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian f42544e04a13

Go patch committed: Mark Call_expression multi-results as result struct

2023-03-28 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend marks a Call_expression multiple results struct as a result struct. In https://go.dev/cl/343873 we stopped padding zero-sized trailing fields in functions that return multiple results where the last result is zero-sized. This CL makes the corresponding change on the c

Go patch committed: Add missing Slice_info_expression::do_traverse

2023-03-22 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend adds the missing Slice_info_expression::do_traverse method. Lack of the method caused https://go.dev/issue/59169. The test case is https://go.dev/cl/478217. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline and GCC 12 branch. Ian 187e

Go patch committed: Define builtin functions

2023-01-17 Thread Ian Lance Taylor via Gcc-patches
This patch by Andrew Pinski defines two builtin functions that are used by the middle-end. This fixes PR 108426. Bootstrapped and tested on x86_64-pc-linux-gnu. Committed to mainline. Ian PR go/108426 * go-gcc.cc (Gcc_backend::Gcc_backend): Define __builtin_ctzl and

Go patch committed: Define __atomic_fetch_add functions

2022-11-09 Thread Ian Lance Taylor via Gcc-patches
This patch to the GCC-specific part of the Go frontend defines the __atomic_fetch_add functions. The frontend only generates calls to the __atomic_add_fetch functions, but in some cases the middle-end can transform the latter into the former. This patch is originally by Marc Poulhiès. This fixes

Go patch committed: Treat S("") as a string constant

2022-10-10 Thread Ian Lance Taylor via Gcc-patches
This Go frontend patch treats S("") as a string constant. The compiler neglected to notice that a conversion from a string constant to a string type was a valid string constant. I didn't add a test case because this only caused a compiler failure when compiling without optimization, which is not

Go patch committed: Only build thunk struct type when needed

2022-10-10 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend delays building the struct type for a go/defer thunk until it is needed. We were building it in the determine_types pass. Now, we delay until the simplify_thunk_statements pass. That ensures that we are consistent in determining whether an argument is constant. Wit

Go patch committed: better argument checking for builtins

2022-10-06 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend by Than McIntosh does some better argument type checking for some builtin functions. This avoids a compiler crash on cases like panic(panic("bad")). This fixes https://go.dev/issue/56071. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainli

Go patch committed: Handle f().x if f returns a zero-sized type

2022-07-16 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend handles the case of f().x when the function f returns a zero-sized type. In that case the GCC interface will have changed f to return void, as the GCC middle-end does not have complete support for zero-sized types. This patch handles the case of void when in a struct

Go patch committed: Don't crash on f(g()) if g returns a zero-sized value

2022-07-15 Thread Ian Lance Taylor via Gcc-patches
This patch to the GCC interface of the Go frontend fixes a crash in f(g()) if g returns a zero-sized value. In that case the GCC interface modifies g to return void, since GCC's middle-end does not have solid support for zero-sized values. This patch detects the f(g()) case and replaces the call

Go patch committed: Propagate array length error marker

2022-07-05 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend propagates the array length error marker farther, to avoid a compiler crash on invalid code. This fixes https://go.dev/issue/53639. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian c70a48a8f8f6a43b35f783b5672c9a3c0a363c31 diff --

Go patch committed: Better error message for unknown package name

2022-07-05 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend gives a better error message for an unknown package name, saying "undefined reference" rather than "expected package". This requires updating a test. This fixes https://go.dev/issue/51237. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to main

Go patch committed: Avoid C++20 keyword requires

2022-07-01 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend renames "requires" to "needs" to avoid the C++20 keyword. Bootstrapped on x86_64-pc-linux-gnu. Committed to mainline. Ian 9d44418664ec8c3e59365901e3ec02e488d9e01c diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 0d49e9e70c6..65f64e0fbfb 100644 --

Go patch committed: Check repeated const expressions in new scop

2022-06-29 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend checks repeated const expressions in new scope, in case they refer to a newly defined name. The test case is const8.go in https://go.dev/cl/414795. This fixes https://go.dev/issue/53585. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainlin

Go patch committed: Use package path with embedded builtin

2022-06-28 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend changes the mangled name of a struct to use the package path with an embedded builtin type. The test case is https://go.dev/cl/414235. This fixes https://go.dev/issue/52856. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 749563

Go patch committed: Permit abstract bool expressions to remain abstract

2022-06-28 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend permits expressions of abstract bool to remain abstract, rather than forcing them into the named type bool. The test case for this is https://go.dev/cl/414755. This fixes https://go.dev/issue/51475. Bootstrarpped and ran Go testsuite on x86_64-pc-linux-gnu. Committe

Go patch committed: Don't use sink as method expression thunk parameter

2022-06-27 Thread Ian Lance Taylor via Gcc-patches
This Go frontend patch avoids using a sink name (_) as a parameter name when creating a method expression thunk. The patch also fixes a couple of cases where the error led to a later compiler crash. The test case is https://go.dev/cl/414336. This fixes https://go.dev/issue/52871. Bootstrapped a

Go patch committed: Always initialize mpfr in integer import

2022-06-27 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend corrects the integer import code to always initialize an mpfr value. The test case for this is https://go.dev/cl/413980. This fixes https://go.dev/issue/52862. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 722750a44a93ce7d23e0

Go patch committed: Use bool for comma-ok if not already boolean

2022-06-24 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend uses bool for a comma-ok statement if the variable already has a type that is not a boolean type. This is a statement like v, ok := m[k] Otherwise we may try to convert an unnamed bool type to an interface type, which will fail. But we don't want to always use

Go patch committed: In Sort_bindings handle same value passed twice

2022-06-23 Thread Ian Lance Taylor via Gcc-patches
This patch by zhangjian to the Go frontend changes Sort_bindings to return false if comparing a value to itself. Apparently some versions of std::sort may pass elements at the same iterator location. This fixes https://go.dev/issue/53483. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.

Go patch committed: unalias types for hash/equality functions

2022-06-23 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend makes sure to unalias types when creating hash/equality functions. This fixes https://go.dev/issue/52846. There is a test case at https://go.dev/cl/413694. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 3e134d9c6716f6acaf3e174

Go patch committed: Skip stubs for ambiguous direct iface methods

2022-06-16 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend by Михаил Аблакатов (Mikhail Ablakatov) avoids generating stubs for ambiguous direct interface methods. The current implementation checks whether it has to generate a stub method for a promoted method of an embedded struct field in Type::build_stub_methods(). If the

Go patch committed: Traverse expressions with exporting consts

2022-05-18 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend by Julia Lapenko traverses expressions when exporting constants. When exporting a constant A that is expressed through a constant B from another package, it is necessary to traverse an expression representing the constant A to generate a sequence of type casts from th

Go patch committed: load LHS subexpressions of op= only once

2022-05-17 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend loads LHS subexpressions of op= assignment only once. This avoids inconsistencies if the variables are changed by evaluating the RHS. This fixes https://go.dev/issue/52811. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. There is a

Go patch committed: Always sort interface parse methods

2022-05-13 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend always sorts interface parse methods. The exporter relies on sorting interface parse methods. It would sort them as it encountered interface types. However, when an interface type is an element of a struct or array type, the exporter might encounter that interface t

Go patch committed: Remove Array_index_expression::is_lvalue_

2022-05-06 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go fronend removes the is_lvalue_ field from Array_index_expression. As of https://go.dev/cl/77510 (https://gcc.gnu.org/pipermail/gcc-patches/2017-November/487697.html) it is never used. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 55e0e

Go patch committed: Reject duplicate bool keys in a map literal

2022-05-06 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend rejects duplicate bool keys in a map literal. This is hardly a common case, but we may as well get it right. This is for https://go.dev/issue/35945 and htps://go.dev/issue/28104. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian

Go patch committed: ignore function type result name in export data

2022-03-08 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend ignores the function type result name when producing export data. This change ensures that we never output a result name in the export data if there is only a single result. Previously we would output a ? if the single result had a name. That made the output unstable

Go patch committed: Call timer function via syscall.

2022-02-13 Thread Ian Lance Taylor via Gcc-patches
It turns out to be painful to require linking against -lrt on GNU/Linux, as that makes it harder to link Go code into C programs. Instead just call the timer syscalls directly. That is what the upstream library does anyhow. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to m

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

2022-02-13 Thread Ian Lance Taylor via Gcc-patches
This patch fixes the Go frontend to not set a bit in the garbage-collection ptrmask bit for a pointer to notinheap type. This is a follow-up to https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590150.html. The test case for this is https://go.dev/cl/385454. Bootstrapped and ran Go testsuit

Go patch committed: Don't warn for print()

2022-02-09 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend stops warning for calls of print(). We used to warn for calls to print(), because it doesn't do anything. However, a Go 1.18 test uses that call, and it is valid Go. Change the compiler to just accept it and compile it; this will produce calls to printlock and printu

Go patch committed: Use nil pointer for zero length string constant

2022-02-09 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend uses a nil pointer for a zero length string constant. We used to pointlessly set the pointer of a zero length string constant to point to a zero byte constant. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 2e2b861e8941c4e9b36b

Go patch committed: treat notinheap types as not being pointers

2022-02-09 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend treats notinheap types as not being pointers. By definition, a type is marked noinheap doesn't contain any pointers that the garbage collector cares about, and neither does a pointer to such a type. Change the type descriptors to consistently treat such types as not

Go patch committed: link against -lrt on GNU/Linux

2022-02-09 Thread Ian Lance Taylor via Gcc-patches
In the Go 1.18 release libgo needs to link against -lrt on GNU/Linux only, to call the timer_create, timer_settime, and timer_delete functions. In preparation this patch changes the gccgo driver to link against -lrt when linking libgo statiically, and the gotools Makefile to link the runtime test

Go patch committed: Recognize Go 1.18 runtime/internal/atomic methods

2022-02-08 Thread Ian Lance Taylor via Gcc-patches
The Go 1.18 library introduces specific types in runtime/internal/atomic. This patch to the Go frontend recognizes and optimizes the methods on those types, as we do with the functions in runtime/internal/atomic. While we're here avoid getting confused by methods in any other package that we reco

Go patch committed: Implement FuncPCABI0, FuncPCABIInternal

2022-02-08 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend and libgo implements the abi.FuncPCABI0 and abi.FuncPCABIInternal functions. The Go 1.18 standard library uses an internal/abi package with two functions that are implemented in the compiler. This patch implements them in the gofrontend, to support the upcoming update

Go patch committed: Add "any" as alias for "interface{}"

2022-02-04 Thread Ian Lance Taylor via Gcc-patches
In the Go 1.18 release the predeclared identifier "any" is a new alias for the type "interface{}". This patch adds this alias to the Go frontend. This requires updating a test. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian d0607656a50cd571d9ab260d040f1dae

Go patch committed: Permit unnamed types when ignoring struct tags

2022-01-06 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend permits converting unnamed types when ignoring struct tags. I think the code was written this way because before conversion could ignore struct tags this case could only arise with named types. Now that conversions permit struct tags to change, this can occur with un

Go patch committed: Remove duplication of Named_object traversal

2022-01-04 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend removes duplication of Named_object traversal code. Adding type parameters was about to add a partial third version. Remove the duplication to avoid that. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 5ef7d6c289350eb94ff6dd62

Re: [gofrontend-dev] Re: Go patch committed: Don't pad epollevent on sparc64 GNU/Linux

2021-12-31 Thread Ian Lance Taylor via Gcc-patches
On Fri, Dec 31, 2021 at 1:32 AM Jakub Jelinek wrote: > > The following patch adjusts the testcase for the above change. > Tested on x86_64-linux, ok for trunk? > > 2021-12-31 Jakub Jelinek > > * gcc.misc-tests/godump-1.c: Adjust for renaming of last > field from _align suffix to

Re: Go patch committed: Don't pad epollevent on sparc64 GNU/Linux

2021-12-31 Thread Jakub Jelinek via Gcc-patches
On Wed, Dec 29, 2021 at 03:54:03PM -0800, Ian Lance Taylor via Gcc-patches wrote: > PR go/103847 > * godump.c (go_force_record_alignment): Name the alignment > field "_". > --- a/gcc/godump.c > +++ b/gcc/godump.c > @@ -651,7 +651,7 @@ go_force_record_alignment (struct obstack *ob, const char > *

Go patch committed: Don't pad epollevent on sparc64 GNU/Linux

2021-12-29 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend, libgo, and the -fgo-dump-spec code avoids padding incorrectly when a zero-sized field is inserted solely for alignment. We avoid this by not padding after a "_" field, and by using "_" fields for padding. This is fine since the padding is only there in case someone

Go patch committed: Traverse func subexprs when creating func descriptors

2021-11-11 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend fixes the Create_func_descriptors pass to traverse the subexpressions of the function in a Call_expression. There are no subexpressions in the normal case of calling a function a method directly, but there are subexpressions when in code like F().M() when F returns an

Go patch committed: Permit compiler directives in parenthesized groups

2021-10-26 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend permits compiler directives in parenthesized groups. The original compiler directive support was only for //line at the start of a line and for //go: comments before function declarations. When support was added for //go:notinheap for types and //go:embed for variabl

Go patch committed: Use nullptr in a couple of cases

2021-10-05 Thread Ian Lance Taylor via Gcc-patches
This Go frontend patch by Than McIntosh uses nullptr in a couple of cases to avoid errors in template matching with some stage1 compilers. Bootstrapped on x86_64-pc-linux-gnu. Committed to mainline. Ian patch f4da52d91658cf73eb95d3d8b4b0fd79c8b0ac23 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/g

Go patch committed: Avoid calling Expression::type before lowering

2021-09-30 Thread Ian Lance Taylor via Gcc-patches
For some future work on the Go frontend it will be annoying to have to make Expression::type work before the lowering pass, so this patch changes the frontend so that that doesn't happen. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian patch.txt 19b5a1147764

Go patch committed: Don't pad zero-sized trailing field in results struct

2021-09-11 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend avoids padding zero-sized trailing fields in the struct created to hold result parameters. This avoids a miscompilation when a function returns multiple results and the last result is zero-sized (this is not a useful way to write a function but it can happen reasonabl

Go patch committed: Correct condition for calling memclrHasPointers

2021-09-10 Thread Ian Lance Taylor via Gcc-patches
This Go frontend patch corrects the condition under which we call memclrHasPointers. When compiling append(s, make([]typ, ln)...), where typ has a pointer, and the append fits within the existing capacity of s, the condition used to clear out the new elements was reversed. This fixes https://gola

Go patch committed: Store pointers to go:notinheap types indirectly

2021-08-12 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend and libgo stores pointers to go:notinheap types indirectly. This provides better support for using cgo with incomplete types. This is the gofrontend version of https://golang.org/cl/264480. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to main

Go patch committed: Don't crash on a, b := int(0)

2021-08-10 Thread Ian Lance Taylor via Gcc-patches
This patch the Go frontend avoids a crash on the invalid code "a, b := int(0)". This fixes GCC PR 101851. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 498e91bf7d6a8000bb4b74f95c404064b8eac644 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE

Re: Go patch committed: Support unsafe.Add and unsafe.Slice

2021-08-07 Thread Ian Lance Taylor via Gcc-patches
On Mon, Aug 2, 2021 at 3:23 PM Ian Lance Taylor wrote: > > The upcoming Go 1.17 release adds two new functions to the unsafe > package: unsafe.Add and unsafe.Slice. These functions must be > implemented in the compiler. This patch implements them for gccgo. > Bootstrapped and ran Go testsuite on

Re: Go patch committed: Be strict about escape analysis of builtin functions

2021-08-06 Thread Ian Lance Taylor via Gcc-patches
On Wed, Aug 4, 2021 at 9:24 PM Ian Lance Taylor wrote: > > This Go frontend patch by Cherry Mui makes the escape analysis pass > stricter about builtin functions In the places where we handle > builtin functions, list all supported ones, and fail if an unexpected > one is seen. So if a new builti

Go patch committed: extend runtime/internal/atomic to sync/atomic

2021-08-05 Thread Ian Lance Taylor via Gcc-patches
This Go patch extends the internal runtime/internal/atomic package to match the externally visible sync/atomic package. This is the gofrontend version of https://golang.org/cl/289152. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian a6b138f257a431f3337f3c6bf5

Go patch committed: Be strict about escape analysis of builtin functions

2021-08-04 Thread Ian Lance Taylor via Gcc-patches
This Go frontend patch by Cherry Mui makes the escape analysis pass stricter about builtin functions In the places where we handle builtin functions, list all supported ones, and fail if an unexpected one is seen. So if a new builtin function is added in the future we can detect it, instead of sil

Go patch committed: Support new language constructs in escape analysis

2021-08-03 Thread Ian Lance Taylor via Gcc-patches
This Go frontend patch by Cherry Mui supports the new language constructs in escape analysis. Previous patches added new language constructs in Go 1.17, specifically, unsafe.Add, unsafe.Slice, and conversion from a slice to a pointer to an array. This patch handles them in the escape analysis. At

Go patch committed: Return two values from selectnbrecv

2021-08-03 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend and libgo changes selectnbrecv to return two values. The only difference between selectnbrecv and selectnbrecv2 is that the latter uses a pointer argument as the second return value from chanrecv. This patch changes selectnbrecv to return the two values from chanrecv

Re: Go patch committed: Allow converting from slice to pointer-to-array

2021-08-03 Thread Ian Lance Taylor via Gcc-patches
On Mon, Aug 2, 2021 at 3:53 PM Ian Lance Taylor wrote: > > The upcoming Go 1.17 release has a new language feature: it permits > conversions from slice types to pointer-to-array types. If the slice > is too short, the conversion panics. This patch implements this new > feature in gccgo. Bootstr

Go patch committed: Allow converting from slice to pointer-to-array

2021-08-02 Thread Ian Lance Taylor via Gcc-patches
The upcoming Go 1.17 release has a new language feature: it permits conversions from slice types to pointer-to-array types. If the slice is too short, the conversion panics. This patch implements this new feature in gccgo. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to m

Go patch committed: Support unsafe.Add and unsafe.Slice

2021-08-02 Thread Ian Lance Taylor via Gcc-patches
The upcoming Go 1.17 release adds two new functions to the unsafe package: unsafe.Add and unsafe.Slice. These functions must be implemented in the compiler. This patch implements them for gccgo. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 06d0437d4a5faca

Go patch committed: Avoid aliases in receiver types

2021-07-19 Thread Ian Lance Taylor via Gcc-patches
This patch changes the Go frontend to avoid aliases in receiver types. If a package declares a method on an alias type, the alias would be used in the export data. This would then trigger a compiler assertion on import: we should not be adding methods to aliases. Fix the problem by ensuring that

Re: Go patch committed: In composite literals use temps only for interfaces

2021-06-29 Thread Ian Lance Taylor via Gcc-patches
On Tue, Jun 29, 2021 at 11:01 AM Ian Lance Taylor wrote: > > This patch to the Go frontend reduces the number of temporaries that > the compiler genrrates for composite literals. For a composite > literal we only need to introduce a temporary variable if we may be > converting to an interface typ

Go patch committed: In composite literals use temps only for interfaces

2021-06-29 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend reduces the number of temporaries that the compiler genrrates for composite literals. For a composite literal we only need to introduce a temporary variable if we may be converting to an interface type, so only do it then. This saves over 80% of compilation time when

Go patch committed: Don't quote ampersand in gccgo.texi

2021-05-27 Thread Ian Lance Taylor via Gcc-patches
This patch removes HTML quoting from the Texinfo file gccgo.html. Committed to mainline. Ian diff --git a/gcc/go/gccgo.texi b/gcc/go/gccgo.texi index ce6b518bb7b..fa0e4882403 100644 --- a/gcc/go/gccgo.texi +++ b/gcc/go/gccgo.texi @@ -495,7 +495,7 @@ like (after importing the @code{os} package):

Go patch committed: Mark global variables TREE_ADDRESSABLE

2021-05-24 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend marks global variables whose address is taken. To implement this, change the backend to use flag bits for variables. This fixes GCC PR 100537. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian PR go/100537 * go-g

Go patch committed: Copy receiver argument for go/defer of method call

2021-03-17 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend copies the receiver argument when compiling a go or defer statement of a method call. Otherwise when using go/defer with a value method the method might incorrectly see a value that was modified after the go/defer statement. The test case for this is https://golang.o

Go patch committed: create temporaries for heap variables

2021-03-11 Thread Ian Lance Taylor via Gcc-patches
The Go frontend generally doesn't create a temporary for an expression that is a variable, because it's normally valid to simply reload thevalue from the variable. However, if the variable is in the heap, then loading the value is a pointer indirection. The process of creating GCC IR can cause th

Go patch committed: All go:embed with import _ "embed"

2021-03-02 Thread Ian Lance Taylor via Gcc-patches
This patch by Michael Matloob fixes the Go frontend to permit //go:embed comments in files that do import _ "embed" The embed spec allows for //go:embed to be used in files that underscore-import package "embed". This is useful for embeds to []byte and string vars because the embed.FS type ma

Go patch committed: Unalias receiver type in export data

2021-02-16 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend unaliases the receiver type when outputting export data for a method. This avoids a crash when importing such a package. The test case for this is https://golang.org/cl/292009. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 91

Go patch committed: Use correct path for string/[]byte embed

2021-02-12 Thread Ian Lance Taylor via Gcc-patches
This patch by Michael Matloob fixes the Go frontend to use the correct path when opening an embedded file for a string or []byte type. For the other embed.FS case we were correctly using the Files mapping, but for string or []byte we were not. Bootstrapped and ran Go testsuite on x86_64-pc-linux-

Go patch committed: Initialize variables with go:embed directives

2021-01-19 Thread Ian Lance Taylor via Gcc-patches
This Go frontend patch initializes variables with go:embed directives. This completes the compiler work for go:embed. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian eed40bca6f2eb3af0c811cf6ec9e123c5bf4907d diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofron

Go patch committed: Read embedcfg file, parse go:embed directives

2021-01-18 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend reads go:embed directives and attaches them to variables. It also reads the embedcfg file passed on the command line. We still don't actually do anything with the directives. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian f6b3e

Go patch committed: Add support for reading embedcfg files

2021-01-14 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend adds support for reading embedcfg files. An embedcfg file is a JSON file created by the go command when it sees a go:embed directive, and passed to the Go frontend via the new -fgo-embedcfg option. This code is not yet called, and does not yet do anything. It's being

Re: Go patch committed: Accept -fgo-embedcfg option

2021-01-05 Thread Ian Lance Taylor via Gcc-patches
On Tue, Jan 5, 2021 at 7:15 AM Jakub Jelinek via Gcc-patches wrote: > > On Tue, Jan 05, 2021 at 11:06:27AM +0100, Andreas Schwab wrote: > > FAIL: compiler driver --help=go option(s): "^ +-.*[^:.]$" absent from > > output: " -fgo-embedcfg=List embedded files via go:embed" > > Fixed thusly

Re: Go patch committed: Accept -fgo-embedcfg option

2021-01-05 Thread Jakub Jelinek via Gcc-patches
On Tue, Jan 05, 2021 at 11:06:27AM +0100, Andreas Schwab wrote: > FAIL: compiler driver --help=go option(s): "^ +-.*[^:.]$" absent from output: > " -fgo-embedcfg=List embedded files via go:embed" Fixed thusly, committed as obvious. 2021-01-05 Jakub Jelinek * lang.opt (fgo-em

Re: Go patch committed: Accept -fgo-embedcfg option

2021-01-05 Thread Andreas Schwab
FAIL: compiler driver --help=go option(s): "^ +-.*[^:.]$" absent from output: " -fgo-embedcfg=List embedded files via go:embed" Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely d

Go patch committed: Accept -fgo-embedcfg option

2021-01-04 Thread Ian Lance Taylor via Gcc-patches
This patch adds a new -fgo-embedcfg option. This will be used by the go command to implement the go:embed directive that is new in the upcoming Go 1.16 release. The option doesn't yet do anything, this is just framework. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mai

Go patch committed: Parenthesize channel type strings as needed

2020-12-23 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend avoids the ambiguity between "chan <- (chan int)" and "chan (<- chan int)". This parenthesizes the same way as the gc compiler. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian a40029e3b185a4b4e16a2a83933f742ff48c9743 diff --git

Go patch committed: Nil-checked pointers and indexes can trap

2020-12-23 Thread Ian Lance Taylor via Gcc-patches
The Go frontend was treating indirections through pointers that had been explicitly checked against nil and slice and string index expressions as non-trapping memory references. That is true for ordinary Go programs, but it isn't true if the programs construct their own memory addresses. In parti

Go patch committed: Remove references to slicecopy and slicestringcopy

2020-12-23 Thread Ian Lance Taylor via Gcc-patches
In the Go frontend, all calls to the runtime functions slicecopy and slicestringcopy were removed in https://golang.org/cl/170005. Remove the remaining mentions. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian b26699c53b257d3354a4cfd3fc9174104f116154 diff --

Go patch committed: Initialize saw_send_stmt locals

2020-12-22 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend initializes a couple of saw_send_stmt local variables that were incorrectly left uninitialized. These are variables in the compiler source, not in the generated code. The C++ compiler wasn't warning because we take their address. This fixes https://golang.org/issue/

Go patch committed: Eliminate the scase.kind field

2020-12-22 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend and libgo eliminates the scase.kind field, saving some space on the stack when running a select statement. Instead of using a kind, the compiler now sorts all the send cases before the receive cases, and gives the default case a special index of -1. This is in prepara

  1   2   3   4   5   6   7   8   9   10   >