aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
AgeCommit message (Collapse)AuthorFilesLines
2018-01-11re PR go/83794 (misc/cgo/test uses gigabytes of memory)Ian Lance Taylor1-1/+1
PR go/83794 misc/cgo/test: avoid endless loop when we can't parse notes Reviewed-on: https://go-review.googlesource.com/87416 From-SVN: r256553
2018-01-11debug/dwarf: formStrp uses a 64-bit value for 64-bit DWARFIan Lance Taylor1-1/+1
No test as the only system I know that uses 64-bit DWARF is AIX. Backport of https://golang.org/cl/84379, which will be in Go 1.11. Backporting now for AIX support in gccgo. Reviewed-on: https://go-review.googlesource.com/87296 From-SVN: r256474
2018-01-10os, syscall: handle _st_timespec for AIX statIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/87197 From-SVN: r256450
2018-01-10libgo: add platform support for SuperHIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/84555 From-SVN: r256446
2018-01-10re PR c/82922 (Request: add -Wstrict-prototypes to -Wextra as K&R style is ↵Ian Lance Taylor1-1/+1
obsolescent) PR c/82922 runtime, syscall: use full prototypes in C code Based on patch by Martin Sebor. Reviewed-on: https://go-review.googlesource.com/86815 From-SVN: r256437
2018-01-10exp: remove exp/proxy and exp/terminal packagesIan Lance Taylor1-1/+1
The exp/proxy package was removed from the master library in https://golang.org/cl/6461056 (August, 2012). The exp/terminal package was removed from the master library in https://golang.org/cl/5970044 (March, 2012). I'm not sure why they lingered in the gofrontend copy, but let's finally remove them now. Reviewed-on: https://go-review.googlesource.com/87138 From-SVN: r256435
2018-01-10cmd/go: check for another GCC error messageIan Lance Taylor1-1/+1
GCC always recognizes the -fsplit-stack option, but then tests whether it is supported by the selected target. If not, it reports cc1: error: ‘-fsplit-stack’ is not supported by this compiler configuration Check for that error message when deciding whether a compiler option works. Reviewed-on: https://go-review.googlesource.com/87137 From-SVN: r256433
2018-01-10runtime: fix makemap calls in __go_construct_mapIan Lance Taylor1-1/+1
The signature of makemap changed with the update to 1.10beta1, but I forgot to update the call from C code. Reviewed-on: https://go-review.googlesource.com/87135 From-SVN: r256431
2018-01-10runtime: work around escaping closure in export_test.goIan Lance Taylor1-1/+1
When compiling runtime, it is not allowed for local variables and closures to be heap allocated. In one test, there is a go statement with a closure. In the gc compiler, it distinguishes capturing variable by value vs. by address, and rewrites it to passing the captured values as arguments. Currently we don't have this, and the escape analysis decides to heap allocate the closure and also the captured variables, which is not allowed. Work around it by passing the variables explicitly. This is in preparation of turning on escape analysis for the runtime. Reviewed-on: https://go-review.googlesource.com/86245 From-SVN: r256419
2018-01-10runtime: noescape some functions/variablesIan Lance Taylor1-1/+1
This is in preparation of turning on escape analysis for the runtime. - In gccgo, systemstack is implemented with mcall, which is not go:noescape. Wrap the closure in noescape so the escape analysis does not think it escapes. - Mark some C functions go:noescape. They do not leak arguments. - Use noescape function to make a few local variables' addresses not escape. The escape analysis cannot figure out because they are assigned to pointer indirections. Reviewed-on: https://go-review.googlesource.com/86244 From-SVN: r256418
2018-01-10cmd/go: add AIX supportIan Lance Taylor1-1/+1
For gccgo code avoid --whole-archive and -(. Use -blibpath instead of -rpath. Reviewed-on: https://go-review.googlesource.com/86956 From-SVN: r256417
2018-01-10libgo: add aix build tagsIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/86936 From-SVN: r256416
2018-01-09compiler: use temporary variable for stack allocationIan Lance Taylor2-4/+15
Currently, allocation expression that can be allocated on stack is implemented with __builtin_alloca, which turns into __morestack_allocate_stack_space, which may call C malloc. This may be slow. Also if this happens during certain runtime functions (e.g. write barrier), bad things might happen (when the escape analysis is enabled for the runtime). Make a temporary variable on stack for the allocation instead. Also remove the write barrier in the assignment in building heap expression when it is stack allocated. Reviewed-on: https://go-review.googlesource.com/86242 From-SVN: r256412
2018-01-09compiler: set captured variable address to nonescape until further floodedIan Lance Taylor2-4/+2
The escape analysis models closures by flowing captured variable address to the closure node. However, the escape state for the address expressions remained unset as ESCAPE_UNKNOWN. This caused later passes to conclude that the address escapes. Fix this by setting its escape state to ESCAPE_NONE first. If it escapes (because the closure escapes), the flood phase will set its escape state properly. Reviewed-on: https://go-review.googlesource.com/86240 From-SVN: r256411
2018-01-09compiler: stack allocate defer thunkIan Lance Taylor3-2/+11
Defer statement may need to allocate a thunk. When it is not inside a loop, this can be stack allocated, as it runs before the function finishes. Reviewed-on: https://go-review.googlesource.com/85639 From-SVN: r256410
2018-01-09compiler: make non-escaping Bound_method_expression not heap allocateIan Lance Taylor2-2/+7
Bound_method_expression needs a closure. Stack allocate the closure when it does not escape. Reviewed-on: https://go-review.googlesource.com/85638 From-SVN: r256407
2018-01-09compiler: move some escape check to Mark_address_takenIan Lance Taylor4-13/+30
Move some check of escape state earlier, from get_backend to Mark_address_taken. So we can reclaim escape analysis Nodes before kicking off the backend (not done in this CL). Also it makes it easier to check variables and closures do not escape when the escape analysis is run for the runtime package (also not done in this CL). Reviewed-on: https://go-review.googlesource.com/85735 From-SVN: r256406
2018-01-09compiler: support go:noescape cross packageIan Lance Taylor4-9/+46
CL 83876 added support of go:noescape pragma, but it only works for functions called from the same package. The pragma did not take effect for exported functions that are not called from the same package. The reason is that top level function declarations are not traversed, and only reached from calls from other functions. This CL adds this support. The Traverse class is extended with a mode to traverse function declarations. Reviewed-on: https://go-review.googlesource.com/85637 From-SVN: r256405
2018-01-09compiler: stack allocate non-escaping makesliceIan Lance Taylor3-14/+61
If we're making a slice of constant size that does not need to escape, allocate it on stack. In lower, do not create temporaries for constant size makeslice, so that it is easier to detect the slice is constant size later. Reviewed-on: https://go-review.googlesource.com/85636 From-SVN: r256404
2018-01-09compiler: delay escaping sliced arraysIan Lance Taylor3-14/+24
Arrays that are sliced are set to escape in type checking, very early in compilation. The escape analysis runs later but cannot undo it. This CL changes it to not escape in the early stage. Later the escape analysis will make it escape when needed. Reviewed-on: https://go-review.googlesource.com/85635 From-SVN: r256403
2018-01-09os/signal/internal/pty: build on SolarisIan Lance Taylor1-1/+1
Patch from Rainer Orth. Reviewed-on: https://go-review.googlesource.com/87037 From-SVN: r256399
2018-01-09compiler: make top-level decl for address-taken non-escaping localsCherry Zhang6-16/+79
If a local variable's address is taken and passed out of its lexical scope, GCC backend may reuse the stack slot for the variable, not knowing it is still live through a pointer. In this case, we create a top-level temporary variable and let the user-defined variable refer to the temporary variable as its storage location. As the temporary variable is declared at the top level, its stack slot will remain live throughout the function. Reviewed-on: https://go-review.googlesource.com/84675 * go-gcc.cc (local_variable): Add decl_var parameter. From-SVN: r256398
2018-01-09compiler: add escape analysis debug hashCherry Zhang8-0/+106
Add a flag -fgo-debug-escape-hash for debugging escape analysis. It takes a binary string, optionally led by a "-", as argument. When specified, the escape analysis runs only on functions whose name is hashed to a value with matching suffix. The "-" sign negates the match, i.e. the analysis runs only on functions with non-matching hash. Reviewed-on: https://go-review.googlesource.com/83878 * lang.opt (fgo-debug-escape-hash): New option. * go-c.h (struct go_create_gogo_args): Add debug_escape_hash field. * go-lang.c (go_langhook_init): Set debug_escape_hash field. * gccgo.texi (Invoking gccgo): Document -fgo-debug-escape-hash. From-SVN: r256393
2018-01-09compiler: use macro Unordered_map instead of std::unordered_mapIan Lance Taylor2-2/+2
Per gcc/go/go-system.h, this is what it is supposed to be, to support wider platforms. Reviewed-on: https://go-review.googlesource.com/85975 From-SVN: r256389
2018-01-09libgo: update to Go1.10beta1Ian Lance Taylor6-32/+97
Update the Go library to the 1.10beta1 release. Requires a few changes to the compiler for modifications to the map runtime code, and to handle some nowritebarrier cases in the runtime. Reviewed-on: https://go-review.googlesource.com/86455 gotools/: * Makefile.am (go_cmd_vet_files): New variable. (go_cmd_buildid_files, go_cmd_test2json_files): New variables. (s-zdefaultcc): Change from constants to functions. (noinst_PROGRAMS): Add vet, buildid, and test2json. (cgo$(EXEEXT)): Link against $(LIBGOTOOL). (vet$(EXEEXT)): New target. (buildid$(EXEEXT)): New target. (test2json$(EXEEXT)): New target. (install-exec-local): Install all $(noinst_PROGRAMS). (uninstall-local): Uninstasll all $(noinst_PROGRAMS). (check-go-tool): Depend on $(noinst_PROGRAMS). Copy down objabi.go. (check-runtime): Depend on $(noinst_PROGRAMS). (check-cgo-test, check-carchive-test): Likewise. (check-vet): New target. (check): Depend on check-vet. Look at cmd_vet-testlog. (.PHONY): Add check-vet. * Makefile.in: Rebuild. From-SVN: r256365
2018-01-06libgo: fix GOARCH_CACHELINESIZE on ia64Ian Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/85256 From-SVN: r256306
2018-01-06go-gcc.cc (Gcc_backend::Gcc_backend): Correct math_function_type_long to ↵Ian Lance Taylor2-1/+6
take one argument. * go-gcc.cc (Gcc_backend::Gcc_backend): Correct math_function_type_long to take one argument. From-SVN: r256305
2018-01-03Add support for MODE_VECTOR_BOOLRichard Sandiford2-1/+15
This patch adds a new mode class to represent vectors of booleans. GET_MODE_BITSIZE (m) / GET_MODE_NUNITS (m) determines the number of bits that are used to represent each boolean; this can be 1 for a fully-packed representation or greater than 1 for an unpacked representation. In the latter case, the value of bits other than the lowest is not significant. These are used by the SVE port to represent predicates. 2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * mode-classes.def (MODE_VECTOR_BOOL): New mode class. * machmode.h (INTEGRAL_MODE_P, VECTOR_MODE_P): Return true for MODE_VECTOR_BOOL. * machmode.def (VECTOR_BOOL_MODE): Document. * genmodes.c (VECTOR_BOOL_MODE): New macro. (make_vector_bool_mode): New function. (complete_mode, emit_mode_wider, emit_mode_adjustments): Handle MODE_VECTOR_BOOL. * lto-streamer-in.c (lto_input_mode_table): Likewise. * rtx-vector-builder.c (rtx_vector_builder::find_cached_value): Likewise. * stor-layout.c (int_mode_for_mode): Likewise. * tree.c (build_vector_type_for_mode): Likewise. * varasm.c (output_constant_pool_2): Likewise. * emit-rtl.c (init_emit_once): Make sure that CONST1_RTX (BImode) and CONSTM1_RTX (BImode) are the same thing. Initialize const_tiny_rtx for MODE_VECTOR_BOOL. * expr.c (expand_expr_real_1): Use VECTOR_MODE_P instead of a list of mode class checks. * tree-vect-generic.c (expand_vector_operation): Use VECTOR_MODE_P instead of a list of mode class checks. (expand_vector_scalar_condition): Likewise. (type_for_widest_vector_mode): Handle BImode as an inner mode. gcc/c-family/ * c-common.c (c_common_type_for_mode): Handle MODE_VECTOR_BOOL. gcc/fortran/ * trans-types.c (gfc_type_for_mode): Handle MODE_VECTOR_BOOL. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Handle MODE_VECTOR_BOOL. gcc/lto/ * lto-lang.c (lto_type_for_mode): Handle MODE_VECTOR_BOOL. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r256202
2018-01-03poly_int: TYPE_VECTOR_SUBPARTSRichard Sandiford2-1/+8
This patch changes TYPE_VECTOR_SUBPARTS to a poly_uint64. The value is encoded in the 10-bit precision field and was previously always stored as a simple log2 value. The challenge was to use this 10 bits to encode the number of elements in variable-length vectors, so that we didn't need to increase the size of the tree. In practice the number of vector elements should always have the form N + N * X (where X is the runtime value), and as for constant-length vectors, N must be a power of 2 (even though X itself might not be). The patch therefore uses the low 8 bits to encode log2(N) and bit 8 to select between constant-length and variable-length vectors. Targets without variable-length vectors continue to use the old scheme. A new valid_vector_subparts_p function tests whether a given number of elements can be encoded. This is false for the vector modes that represent an LD3 or ST3 vector triple (which we want to treat as arrays of vectors rather than single vectors). Most of the patch is mechanical; previous patches handled the changes that weren't entirely straightforward. 2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (TYPE_VECTOR_SUBPARTS): Turn into a function and handle polynomial numbers of units. (SET_TYPE_VECTOR_SUBPARTS): Likewise. (valid_vector_subparts_p): New function. (build_vector_type): Remove temporary shim and take the number of units as a poly_uint64 rather than an int. (build_opaque_vector_type): Take the number of units as a poly_uint64 rather than an int. * tree.c (build_vector_from_ctor): Handle polynomial TYPE_VECTOR_SUBPARTS. (type_hash_canon_hash, type_cache_hasher::equal): Likewise. (uniform_vector_p, vector_type_mode, build_vector): Likewise. (build_vector_from_val): If the number of units is variable, use build_vec_duplicate_cst for constant operands and VEC_DUPLICATE_EXPR otherwise. (make_vector_type): Remove temporary is_constant (). (build_vector_type, build_opaque_vector_type): Take the number of units as a poly_uint64 rather than an int. (check_vector_cst): Handle polynomial TYPE_VECTOR_SUBPARTS and VECTOR_CST_NELTS. * cfgexpand.c (expand_debug_expr): Likewise. * expr.c (count_type_elements, categorize_ctor_elements_1): Likewise. (store_constructor, expand_expr_real_1): Likewise. (const_scalar_mask_from_tree): Likewise. * fold-const-call.c (fold_const_reduction): Likewise. * fold-const.c (const_binop, const_unop, fold_convert_const): Likewise. (operand_equal_p, fold_vec_perm, fold_ternary_loc): Likewise. (native_encode_vector, vec_cst_ctor_to_array): Likewise. (fold_relational_const): Likewise. (native_interpret_vector): Likewise. Change the size from an int to an unsigned int. * gimple-fold.c (gimple_fold_stmt_to_constant_1): Handle polynomial TYPE_VECTOR_SUBPARTS. (gimple_fold_indirect_ref, gimple_build_vector): Likewise. (gimple_build_vector_from_val): Use VEC_DUPLICATE_EXPR when duplicating a non-constant operand into a variable-length vector. * hsa-brig.c (hsa_op_immed::emit_to_buffer): Handle polynomial TYPE_VECTOR_SUBPARTS and VECTOR_CST_NELTS. * ipa-icf.c (sem_variable::equals): Likewise. * match.pd: Likewise. * omp-simd-clone.c (simd_clone_subparts): Likewise. * print-tree.c (print_node): Likewise. * stor-layout.c (layout_type): Likewise. * targhooks.c (default_builtin_vectorization_cost): Likewise. * tree-cfg.c (verify_gimple_comparison): Likewise. (verify_gimple_assign_binary): Likewise. (verify_gimple_assign_ternary): Likewise. (verify_gimple_assign_single): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * tree-ssa-forwprop.c (simplify_vector_constructor): Likewise. (simplify_bitfield_ref, is_combined_permutation_identity): Likewise. * tree-vect-data-refs.c (vect_permute_store_chain): Likewise. (vect_grouped_load_supported, vect_permute_load_chain): Likewise. (vect_shift_permute_load_chain): Likewise. * tree-vect-generic.c (nunits_for_known_piecewise_op): Likewise. (expand_vector_condition, optimize_vector_constructor): Likewise. (lower_vec_perm, get_compute_type): Likewise. * tree-vect-loop.c (vect_determine_vectorization_factor): Likewise. (get_initial_defs_for_reduction, vect_transform_loop): Likewise. * tree-vect-patterns.c (vect_recog_bool_pattern): Likewise. (vect_recog_mask_conversion_pattern): Likewise. * tree-vect-slp.c (vect_supported_load_permutation_p): Likewise. (vect_get_constant_vectors, vect_transform_slp_perm_load): Likewise. * tree-vect-stmts.c (perm_mask_for_reverse): Likewise. (get_group_load_store_type, vectorizable_mask_load_store): Likewise. (vectorizable_bswap, simd_clone_subparts, vectorizable_assignment) (vectorizable_shift, vectorizable_operation, vectorizable_store) (vectorizable_load, vect_is_simple_cond, vectorizable_comparison) (supportable_widening_operation): Likewise. (supportable_narrowing_operation): Likewise. * tree-vector-builder.c (tree_vector_builder::binary_encoded_nelts): Likewise. * varasm.c (output_constant): Likewise. gcc/ada/ * gcc-interface/utils.c (gnat_types_compatible_p): Handle polynomial TYPE_VECTOR_SUBPARTS. gcc/brig/ * brigfrontend/brig-to-generic.cc (get_unsigned_int_type): Handle polynomial TYPE_VECTOR_SUBPARTS. * brigfrontend/brig-util.h (gccbrig_type_vector_subparts): Likewise. gcc/c-family/ * c-common.c (vector_types_convertible_p, c_build_vec_perm_expr) (convert_vector_to_array_for_subscript): Handle polynomial TYPE_VECTOR_SUBPARTS. (c_common_type_for_mode): Check valid_vector_subparts_p. * c-pretty-print.c (pp_c_initializer_list): Handle polynomial VECTOR_CST_NELTS. gcc/c/ * c-typeck.c (comptypes_internal, build_binary_op): Handle polynomial TYPE_VECTOR_SUBPARTS. gcc/cp/ * constexpr.c (cxx_eval_array_reference): Handle polynomial VECTOR_CST_NELTS. (cxx_fold_indirect_ref): Handle polynomial TYPE_VECTOR_SUBPARTS. * call.c (build_conditional_expr_1): Likewise. * decl.c (cp_finish_decomp): Likewise. * mangle.c (write_type): Likewise. * typeck.c (structural_comptypes): Likewise. (cp_build_binary_op): Likewise. * typeck2.c (process_init_constructor_array): Likewise. gcc/fortran/ * trans-types.c (gfc_type_for_mode): Check valid_vector_subparts_p. gcc/lto/ * lto-lang.c (lto_type_for_mode): Check valid_vector_subparts_p. * lto.c (hash_canonical_type): Handle polynomial TYPE_VECTOR_SUBPARTS. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Check valid_vector_subparts_p. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r256197
2018-01-03Update copyright years.Jakub Jelinek14-14/+16
From-SVN: r256169
2018-01-03gcc.c (process_command): Update copyright notice dates.Jakub Jelinek2-1/+5
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: r256166
2017-12-22compiler: do not propagate address-taken of a slice element to the sliceIan Lance Taylor3-3/+10
Array_index_expression may be used for indexing/slicing array or slice. If a slice element is address taken, the slice itself is not necessarily address taken. Only propagate address-taken for arrays. Reviewed-on: https://go-review.googlesource.com/83877 From-SVN: r255977
2017-12-22compiler: bring escape analysis mostly in line with gc compilerIan Lance Taylor7-516/+888
This CL ports the latest (~Go 1.10) escape analysis code from the gc compiler. Changes include: - In the gc compiler, the variable expression is represented with the variable node itself (ONAME). It is the same node used in the AST for multiple var expressions for the same variable. In our case, the var expressions nodes are distinct nodes. We need to propagate the escape state from/to the underlying variable in getter and setter. We already do it in the setter. Do it in the getter as well. - At the point of escape analysis, some AST constructs have not been lowered to runtime calls, for example, map literal construction and some builtin calls. Change the analysis to work on the non-lowered AST constructs instead of call expressions for them. For this to work, the analysis needs to look into Builtin_call_expression. Move its class definition from expressions.cc to expressions.h, and add necessary accessors. Also fix bugs in other runtime call handlings (selectsend, ifaceX2Y2, etc.). - Handle closures properly. The analysis tracks the function reference expression, and the escape state is propagated to the underlying heap expression for get_backend to do stack allocation for non-escaping closures. - Fix add_dereference. Before, this was doing expr->deref(), which undoes an indirection instead of add one. In the gc compiler, it adds a level of indirection, which is modeled as an OIND node regardless of the type of the expression. We can't do this for non-pointer typed expression, otherwise it will result in a type error. Instead, we model it with a special flavor of Node, "indirect". The flood phase handles this by incrementing its level. - Slicing of an array was not handled correctly. The gc compiler has an implicit (compiler inserted) OADDR node for the array, so the analysis is actually performed on the address of the array. We don't have this implicit address-of expression in the AST. Instead, we model this by adding an implicit child to the Node of the Array_index_expression representing slicing of an array. - Array_index_expression may represent indexing or slicing. The code distinguishes them by looking at whether the type of the expression is a slice. This does not work if the slice element is a slice. Instead, check whether its end() is NULL. - Temporary references was handled only in a limited case, as part of address-of expression. This CL handles it in general. The analysis uses the Temporary_statement as the point of tracking, and forwards Temporary_reference_expression to the underlying statement when needed. - Handle call return value flows, escpecially multiple return values. This includes porting part of CL 8202, CL 20102, and other fixes. - Support go:noescape pragma. - Add special handling for self assignment like b.buf = b.buf[m:n]. (CL 3162) - Remove ESCAPE_SCOPE, which was treated essentially the same as ESCAPE_HEAP, and was removed from the gc compiler. (CL 32130) - Run flood phase until fix point. (CL 30693) - Unnamed parameters do not escape. (CL 38600) - Various small bug fixes and improvements. "make check-go" passes except the one test in math/big, when the escape analysis is on. The escape analysis is still not run by default. Reviewed-on: https://go-review.googlesource.com/83876 From-SVN: r255976
2017-12-22compiler: improve escape analysis diagnosticsIan Lance Taylor5-47/+97
This CL brings escape analysis diagnostics closer to the gc compiler's. This makes porting and debugging escape analysis code easier. A few changes: - In the gc compiler, the variable expression is represented with the variable node itself (ONAME), the location of which is the location of definition. We add a definition_location method to Node, and make use of it when the gc compiler emits diagnostics at the definition locations. - In the gc compiler, methods are named T.M or (*T).M. Add the type to the method name when possible. - Print "moved to heap" messages only for variables. - Reduce some duplicated diagnostics. - Print "does not escape" messages in more situations which the gc compiler does. - Remove the special handling for closure numbers. In gofrontend, closures are named "$nested#" where # is a global counter starting from 0, whereas in the gc compiler they are named "outer.func#" where # is a per-function counter starting from 1. We tried to adjust the closure name to better matching the ones in the gc compiler, however, it cannot match exactly because of the difference of the counter. Instead, just print "outer.$nested#". Reviewed-on: https://go-review.googlesource.com/83875 From-SVN: r255967
2017-12-16os: pass -s to hostname on AIXIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/79375 From-SVN: r255738
2017-12-16syscall: emulate Flock on AIXIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/79095 From-SVN: r255737
2017-12-12go-lang.c (TARGET_AIX): Define if not defined.Tony Reix2-1/+11
* go-lang.c (TARGET_AIX): Define if not defined. (go_langhook_init): Set nil_check_size_threshold to -1 on AIX. Co-Authored-By: Ian Lance Taylor <iant@golang.org> From-SVN: r255582
2017-12-06libgo: remove -fplan9-extensions from CFLAGSIan Lance Taylor1-1/+1
Remove -fplan9-extensions from the CFLAGS used for libgo (no longer needed since the runtime was converted from C to Go). Reviewed-on: https://go-review.googlesource.com/82177 From-SVN: r255445
2017-12-06compiler: handle set-and-use-temp in nilcheck codeIan Lance Taylor2-3/+16
Change the code in Unary_expression::do_get_backend that introduces explicit nil checks for dereference operations to special case set-and-use-temporary expressions. For this case it is better to generate an explicit reference of the temp in the final conditional (avoids introducing tree sharing). Reviewed-on: https://go-review.googlesource.com/81915 From-SVN: r255442
2017-12-05compiler: no nil check needed for closure var dereferencesIan Lance Taylor2-3/+4
Add the "no nil check needed" annotation to the dereference operations created in Parse::enclosing_var_reference (this is safe since the closure object is under control of the compiler, and pointer fields in it will always be non-nil). Reviewed-on: https://go-review.googlesource.com/81795 From-SVN: r255400
2017-12-02runtime: export cgoCheck functionsIan Lance Taylor1-1/+1
The functions cgoCheckPointer and cgoCheckResult are called by code generated by cgo. That means that we need to export them using go:linkname, as otherwise they are local symbols. The cgo code currently uses weak references to only call the symbols if they are defined, which is why it has been working--the cgo code has not been doing any checks. Reviewed-on: https://go-review.googlesource.com/80295 From-SVN: r255347
2017-12-02compiler: avoid GCC middle-end control warningsIan Lance Taylor7-13/+45
GCC has started emitting "control reaches end of non-void function" warnings. Avoid them for Go by 1) marking the builtin function panic and the compiler-generated function __go_runtime_error as not returning and 2) adding a default case to the switch used for select statements that simply calls __builtin_unreachable. Fixes golang/go#22767 Reviewed-on: https://go-review.googlesource.com/80416 * go-gcc.cc (Gcc_backend::Gcc_backend): Define __builtin_unreachable. (Gcc_backend::function): Add does_not_return parameter. From-SVN: r255346
2017-12-01compiler: introduce size threshold for nil checksThan McIntosh13-81/+220
Add a new control variable to the Gogo class that stores the size threshold for nil checks. This value can be used to control the policy for deciding when a given deference operation needs a check and when it does not. A size threshold of -1 means that every potentially faulting dereference needs an explicit check (and branch to error call). A size threshold of K (where K > 0) means that if the size of the object being dereferenced is >= K, then we need a check. Reviewed-on: https://go-review.googlesource.com/80996 * go-c.h (go_create_gogo_args): Add nil_check_size_threshold field. * go-lang.c (go_langhook_init): Set nil_check_size_threshold. From-SVN: r255340
2017-11-30compiler: don't make map zero value constantIan Lance Taylor2-4/+4
The map zero value is a common symbol, and it doesn't really make sense to have a constant common symbol. Current GCC has started to reject this case, probably as part of the fix for PR 83100. Reviewed-on: https://go-review.googlesource.com/80877 From-SVN: r255266
2017-11-28tree.def (SWITCH_EXPR): Change from 3 operand to 2 operand tree.Jakub Jelinek2-2/+7
* tree.def (SWITCH_EXPR): Change from 3 operand to 2 operand tree. Adjust comment. * tree.h (SWITCH_LABELS): Remove. * gimplify.c (gimplify_switch_expr): Don't test SWITCH_LABELS, assert SWITCH_BODY is non-NULL. * tree-pretty-print.c (dump_generic_node): Remove SWITCH_LABELS handling. * tree.c (block_may_fallthru): Always return true; for SWITCH_EXPR. c/ * c-typeck.c (c_start_case): Build SWITCH_EXPR using build2 instead of build3. cp/ * cp-gimplify.c (genericize_switch_stmt): Build SWITCH_EXPR using build2_loc instead of build3_loc. ada/ * gcc-interface/trans.c (Case_Statement_to_gnu): Build SWITCH_EXPR using build2 instead of build3. jit/ * jit-playback.c (add_switch): Build SWITCH_EXPR using build2 instead of build3. Formatting fixes. Adjust funciton comment. fortran/ * trans-decl.c (gfc_trans_entry_master_switch): Build SWITCH_EXPR using fold_build2_loc instead of fold_build3_loc. * trans-io.c (io_result): Likewise. * trans-stmt.c (gfc_trans_integer_select, gfc_trans_character_select): Likewise. go/ * go-gcc.cc (Gcc_backend::switch_statement): Build SWITCH_EXPR using build2_loc instead of build3_loc. brig/ * brigfrontend/brig-branch-inst-handler.cc (brig_branch_inst_handler::operator): Build SWITCH_EXPR using build2 instead of build3. From-SVN: r255192
2017-11-23cmd/go, go/internal/gccgoimporter: pass -X to ar on AIXIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/72930 From-SVN: r255090
2017-11-22compiler: make comparison operator() methods constIan Lance Taylor4-4/+4
This is required for new versions of libstdc++ in C++17 mode. Fixes GCC PR 83102. Reviewed-on: https://go-review.googlesource.com/79396 From-SVN: r255062
2017-11-22libgo: don't use grep -q in mksigtab.shIan Lance Taylor1-1/+1
Solaris grep does not support the -q option. Reviewed-on: https://go-review.googlesource.com/79239 From-SVN: r255042
2017-11-21libgo: fix makefile bugletIan Lance Taylor1-1/+1
Fix a small bug in the libgo Makefile recipe that constructs the directory from which to pick up libgcc_s.so ; the gccgo invocation with -print-libgcc-file-name was missing the flags, which meant that for -m32 builds we'd see the 64-bit libgcc dir. Reviewed-on: https://go-review.googlesource.com/78836 From-SVN: r254984
2017-11-21compiler: report error for ++/-- applied to a non-numeric typeIan Lance Taylor2-1/+6
This avoids a compiler crash. Fixes GCC PR 83071. Reviewed-on: https://go-review.googlesource.com/78875 From-SVN: r254983