aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend
AgeCommit message (Collapse)AuthorFilesLines
2022-02-13runtime: call timer functions via syscallIan Lance Taylor1-1/+1
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. gcc/go/ * gospec.cc: Revert 2022-02-09 change: (RTLIB, RT_LIBRARY): Don't define. (lang_specific_driver): Don't add -lrt if linking statically on GNU/Linux. gotools/ * configure.ac: Revert 2022-02-09 change: (RT_LIBS): Don't define. * Makefile.am (check-runtime): Don't set GOLIBS to $(RT_LIBS). * configure, Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/385475
2022-02-13compiler: don't set ptrmask bit for pointer to notinheap typeIan Lance Taylor2-7/+4
Test case is https://go.dev/cl/385454. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/385474
2022-02-11libgo: update to Go1.18beta2Ian Lance Taylor1-1/+1
gotools/ * Makefile.am (go_cmd_cgo_files): Add ast_go118.go (check-go-tool): Copy golang.org/x/tools directories. * Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384695
2022-02-09compiler: don't warn for print()Ian Lance Taylor2-11/+2
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 printunlock, and nothing else. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384355
2022-02-09compiler: use nil pointer for zero length string constantIan Lance Taylor2-4/+10
We used to pointlessly set the pointer of a zero length string constant to point to a zero byte constant. Instead, just use nil. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384354
2022-02-09compiler: treat notinheap types as not being pointersIan Lance Taylor4-8/+31
By definition, a type is marked notinheap 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 being pointers, by setting ptrdata to 0 and gcdata to nil. Change-Id: Id8466555ec493456ff5ff09f1670551414619bd2 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384118 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-02-08compiler: recognize Go 1.18 runtime/internal/atomic methodsIan Lance Taylor3-2/+160
The Go 1.18 library introduces specific types in runtime/internal/atomic. Recognize and optimize 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 recognize specially. * go-gcc.cc (Gcc_backend::Gcc_backend): Define builtins __atomic_load_1 and __atomic_store_1. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/383654
2022-02-08compiler, internal/abi: implement FuncPCABI0, FuncPCABIInternalIan Lance Taylor2-1/+45
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 to 1.18. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/383514
2022-02-04compiler: accept "any" as an alias for "interface{}"Ian Lance Taylor2-1/+10
For golang/go#33232 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/382248
2022-01-20runtime: build panic32.go on amd64p32Ian Lance Taylor1-1/+1
Fixes https://gcc.gnu.org/PR104149 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/380054
2022-01-06compiler: permit converting unnamed types when ignoring struct tagsIan Lance Taylor2-3/+2
Test case is https://golang.org/cl/375796. Fixes golang/go#50439 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/375797
2022-01-04compiler: remove duplication of Named_object traversalIan Lance Taylor3-151/+100
Adding type parameters was about to add a partial third version. Remove the duplication to avoid that. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/375234
2021-12-29compiler, libgo: don't pad sparc64-linux epolleventIan Lance Taylor2-4/+13
Change the compiler to not add zero padding because of zero-sized fields named "_", since those can't be referenced anyhow. Change the sparc-linux64 epollevent struct to name the alignment field "_", to avoid zero padding. Fixes PR go/103847 PR go/103847 * godump.c (go_force_record_alignment): Name the alignment field "_". Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/374914
2021-11-11compiler: traverse func subexprs when creating func descriptorsIan Lance Taylor4-11/+61
Fix 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 interface type. Forgetting to traverse the function subexpressions was almost entirely hidden by the fact that we also created the necessary thunks in Bound_method_expression::do_flatten and Interface_field_reference_expression::do_get_backend. However, when the thunks were created there, they did not go through the order_evaluations pass. This almost always worked, but failed in the case in which the function being thunked returned multiple results, as order_evaluations takes the necessary step of moving the Call_expression into its own statement, and that would not happen when order_evaluations was not called. Avoid hiding errors like this by changing those methods to only lookup the previously created thunk, rather than creating it if it was not already created. The test case for this is https://golang.org/cl/363156. Fixes https://golang.org/issue/49512 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/363274
2021-10-26compiler: permit compiler directives in parenthesized groupsIan Lance Taylor5-78/+89
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 variables the code did not adapt to permit spaces before the comment or to permit the comments in var() or type() groups. This change corrects those omissions. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/358699
2021-10-05compiler: workaround for C++ build template matching quirkThan McIntosh2-3/+3
Tweak a couple of places in the types code to use nullptr instead of NULL to work around a template matching quirk when using certain build compilers. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/354151
2021-09-30compiler: avoid calling Expression::type before loweringIan Lance Taylor4-23/+69
This is a minor cleanup to ensure that the various Expression::do_type methods don't have to worry about the possibility that the Expression has not been lowered. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/353140
2021-09-21runtime: set runtime.GOROOT value at build timeIan Lance Taylor1-1/+1
In Go 1.17 the gc toolchain changed to set runtime.GOROOT in cmd/link (previously it was runtime/internal/sys.GOROOT). Do the same in libgo. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/351313 gotools/: * Makefile.am (check-runtime): Add goroot.go to --extrafiles. * Makefile.in: Regenerate.
2021-09-16libgo: update to go1.17.1 releaseIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/350414
2021-09-11compiler: don't pad zero-sized trailing field in results structIan Lance Taylor3-3/+19
Nothing can take the address of that field anyhow. Fixes PR go/101994 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/343873
2021-09-10compiler: correct condition for calling memclrHasPointersIan Lance Taylor2-2/+2
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. Fixes golang/go#47771 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/344189
2021-09-07runtime: use hash32, not hash64, for amd64p32, mips64p32, mips64p32leIan Lance Taylor1-1/+1
Fixes PR go/102102 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/348015
2021-09-05libgo: update to final Go 1.17 releaseIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/343729
2021-08-14libgo: various fixes for Solaris supportIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/342189
2021-08-13runtime: use C cast syntax in stack.cIan Lance Taylor1-1/+1
Didn't notice earlier because this code is only used on systems that do not support -fsplit-stack. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/342051
2021-08-12libgo: update to Go1.17rc2Ian Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341629
2021-08-12compiler: store pointers to go:notinheap types indirectlyIan Lance Taylor4-18/+92
This is the gofrontend version of https://golang.org/cl/264480. For golang/go#42076 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/340609
2021-08-10compiler: don't crash on a, b := int(0)Ian Lance Taylor2-3/+14
Fixes PR go/101851 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341330
2021-08-07compiler: support export/import of unsafe.Add/SliceIan Lance Taylor8-29/+130
For golang/go#19367 For golang/go#40481 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/340549
2021-08-06compiler: make escape analysis more strict about runtime callsCherry Mui2-2/+47
Following the previous CL, in the escape analysis list all the expected runtime calls, and fail if an unexpected one is seen. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/340397
2021-08-05runtime: extend internal atomics to comply with sync/atomicIan Lance Taylor2-26/+24
This is the gofrontend version of https://golang.org/cl/289152. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/339690
2021-08-04compiler: make escape analysis more robust about builtin functionsCherry Mui2-3/+55
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 silently treating it as nonescaping. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/339992
2021-08-03compiler: support new language constructs in escape analysisCherry Mui4-50/+134
Previous CLs add new language constructs in Go 1.17, specifically, unsafe.Add, unsafe.Slice, and conversion from a slice to a pointer to an array. This CL handles them in the escape analysis. At the point of the escape analysis, unsafe.Add and unsafe.Slice are still builtin calls, so just handle them in data flow. Conversion from a slice to a pointer to an array has already been lowered to a combination of compound expression, conditional expression and slice info expressions, so handle them in the escape analysis. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/339671
2021-08-03compile, runtime: make selectnbrecv return two valuesIan Lance Taylor3-35/+34
The only different between selectnbrecv and selectnbrecv2 is the later set the input pointer value by second return value from chanrecv. So by making selectnbrecv return two values from chanrecv, we can get rid of selectnbrecv2, the compiler can now call only selectnbrecv and generate simpler code. This is the gofrontend version of https://golang.org/cl/292890. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/339529
2021-08-03compiler: check slice to pointer-to-array conversion element typeIan Lance Taylor3-3/+8
When checking a slice to pointer-to-array conversion, I forgot to verify that the elements types are identical. For golang/go#395 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/339329
2021-08-02compiler, runtime: allow slice to array pointer conversionIan Lance Taylor4-3/+64
Panic if the slice is too short. For golang/go#395 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/338630
2021-08-02compiler, runtime: support unsafe.Add and unsafe.SliceIan Lance Taylor5-2/+253
For golang/go#19367 For golang/go#40481 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/338949
2021-07-19compiler: avoid aliases in receiver typesIan Lance Taylor4-1/+100
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 receiver types do not use alias types. This seems preferable to consistently avoiding aliases in export data, as aliases can cross packages. And it's painful to try to patch this while writing the export data, as at that point all the types are known. Test case is https://golang.org/cl/335172. Fixes golang/go#47131 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/335729
2021-07-09runtime: remove direct assignments to memory locationsIan Lance Taylor1-1/+1
PR bootstrap/101374 They cause a warning with the updated GCC -Warray-bounds option. Replace them with calls to abort, which for our purposes is fine. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/333409
2021-06-29compiler: don't generate temporaries for composite literalsIan Lance Taylor3-104/+7
We were generating temporaries for composite literals when a conversion to interface type was required. However, Cherry's https://golang.org/cl/176459 changed the compiler to insert explicit type conversions. And those explicit type conversions insert the required temporaries in Type_conversion_expression::do_flatten. So in practice the composite literal do_flatten methods would never insert temporaries, as the values they see would always be multi_eval_safe. So just remove the unnecessary do_flatten methods. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/331691
2021-06-29compiler: in composite literals use temps only for interfacesIan Lance Taylor2-5/+14
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 using gccgo to compile cmd/internal/obj/x86, as the GCC middle-end spends a lot of time pointlessly computing interactions between temporary variables. For PR debug/101064 For golang/go#46600 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/331513
2021-06-10libgo: update to Go1.16.5 releaseIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/326772
2021-05-24compiler: mark global variables whose address is takenIan Lance Taylor6-134/+171
To implement this, change the backend to use flag bits for variables. Fixes https://gcc.gnu.org/PR100537 PR go/100537 * go-gcc.cc (class Gcc_backend): Update methods that create variables to take a flags parameter. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/322129
2021-05-18gofrontend: revert startswith changeIan Lance Taylor1-1/+1
This file is copied from a different repo and should not be changed directly in the GCC repo.
2021-05-18libgo: update configure to current sourcesIan Lance Taylor1-1/+1
Change-Id: I12766baf02bfdf2233f1c5bde1a270f06b020aa7 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/321076 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-10Come up with startswith function.Martin Liska1-1/+1
gcc/ada/ChangeLog: * gcc-interface/utils.c (def_builtin_1): Use startswith function instead of strncmp. gcc/analyzer/ChangeLog: * sm-file.cc (is_file_using_fn_p): Use startswith function instead of strncmp. gcc/ChangeLog: * builtins.c (is_builtin_name): Use startswith function instead of strncmp. * collect2.c (main): Likewise. (has_lto_section): Likewise. (scan_libraries): Likewise. * coverage.c (coverage_checksum_string): Likewise. (coverage_init): Likewise. * dwarf2out.c (is_cxx): Likewise. (gen_compile_unit_die): Likewise. * gcc-ar.c (main): Likewise. * gcc.c (init_spec): Likewise. (read_specs): Likewise. (execute): Likewise. (check_live_switch): Likewise. * genattrtab.c (write_attr_case): Likewise. (IS_ATTR_GROUP): Likewise. * gencfn-macros.c (main): Likewise. * gengtype.c (type_for_name): Likewise. (gen_rtx_next): Likewise. (get_file_langdir): Likewise. (write_local): Likewise. * genmatch.c (get_operator): Likewise. (get_operand_type): Likewise. (expr::gen_transform): Likewise. * genoutput.c (validate_optab_operands): Likewise. * incpath.c (add_sysroot_to_chain): Likewise. * langhooks.c (lang_GNU_C): Likewise. (lang_GNU_CXX): Likewise. (lang_GNU_Fortran): Likewise. (lang_GNU_OBJC): Likewise. * lto-wrapper.c (run_gcc): Likewise. * omp-general.c (omp_max_simt_vf): Likewise. * omp-low.c (omp_runtime_api_call): Likewise. * opts-common.c (parse_options_from_collect_gcc_options): Likewise. * read-rtl-function.c (function_reader::read_rtx_operand_r): Likewise. * real.c (real_from_string): Likewise. * selftest.c (assert_str_startswith): Likewise. * timevar.c (timer::validate_phases): Likewise. * tree.c (get_file_function_name): Likewise. * ubsan.c (ubsan_use_new_style_p): Likewise. * varasm.c (default_function_rodata_section): Likewise. (incorporeal_function_p): Likewise. (default_section_type_flags): Likewise. * system.h (startswith): Define startswith. gcc/c-family/ChangeLog: * c-ada-spec.c (print_destructor): Use startswith function instead of strncmp. (dump_ada_declaration): Likewise. * c-common.c (disable_builtin_function): Likewise. (def_builtin_1): Likewise. * c-format.c (check_tokens): Likewise. (check_plain): Likewise. (convert_format_name_to_system_name): Likewise. gcc/c/ChangeLog: * c-aux-info.c (affix_data_type): Use startswith function instead of strncmp. * c-typeck.c (build_function_call_vec): Likewise. * gimple-parser.c (c_parser_gimple_parse_bb_spec): Likewise. gcc/cp/ChangeLog: * decl.c (duplicate_decls): Use startswith function instead of strncmp. (cxx_builtin_function): Likewise. (omp_declare_variant_finalize_one): Likewise. (grokfndecl): Likewise. * error.c (dump_decl_name): Likewise. * mangle.c (find_decomp_unqualified_name): Likewise. (write_guarded_var_name): Likewise. (decl_tls_wrapper_p): Likewise. * parser.c (cp_parser_simple_type_specifier): Likewise. (cp_parser_tx_qualifier_opt): Likewise. * pt.c (template_parm_object_p): Likewise. (dguide_name_p): Likewise. gcc/d/ChangeLog: * d-builtins.cc (do_build_builtin_fn): Use startswith function instead of strncmp. * dmd/dinterpret.c (evaluateIfBuiltin): Likewise. * dmd/dmangle.c: Likewise. * dmd/hdrgen.c: Likewise. * dmd/identifier.c (Identifier::toHChars2): Likewise. gcc/fortran/ChangeLog: * decl.c (variable_decl): Use startswith function instead of strncmp. (gfc_match_end): Likewise. * gfortran.h (gfc_str_startswith): Likewise. * module.c (load_omp_udrs): Likewise. (read_module): Likewise. * options.c (gfc_handle_runtime_check_option): Likewise. * primary.c (match_arg_list_function): Likewise. * trans-decl.c (gfc_get_symbol_decl): Likewise. * trans-expr.c (gfc_conv_procedure_call): Likewise. * trans-intrinsic.c (gfc_conv_ieee_arithmetic_function): Likewise. gcc/go/ChangeLog: * gofrontend/runtime.cc (Runtime::name_to_code): Use startswith function instead of strncmp. gcc/objc/ChangeLog: * objc-act.c (objc_string_ref_type_p): Use startswith function instead of strncmp. * objc-encoding.c (encode_type): Likewise. * objc-next-runtime-abi-02.c (has_load_impl): Likewise.
2021-04-12libgo: update to Go1.16.3 releaseIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/309490
2021-03-17compiler: copy receiver argument for go/defer of method callIan Lance Taylor3-2/+29
Test case is https://golang.org/cl/302371. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/302270
2021-03-15libgo: update to Go 1.16.2 releaseIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/301459
2021-03-12misc/cgo/testcarchive: don't use == for string equality in C codeIan Lance Taylor1-1/+1
Backport of https://golang.org/cl/300993. For PR go/99553 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/301458