summaryrefslogtreecommitdiff
path: root/gcc/ada/s-vallld.adb
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-02-07 09:30:58 -0800
committerH.J. Lu <hjl.tools@gmail.com>2016-02-17 12:49:32 -0800
commitf7279941c6631f049360687029f464205c878bb4 (patch)
tree44fa8417f1c27fb6d520a0357aaacf704ce8d35c /gcc/ada/s-vallld.adb
parent1ed49e03e6ad9dc02dd460705125d7f579d05aeb (diff)
downloadgcc-hjl/pr60336/x86.tar.gz
Add TYPE_EMPTY_RECORD for C++ empty classhjl/pr60336/x86
Empty record should be returned and passed the same way in C and C++. This patch overloads a bit, side_effects_flag, in tree_base for C++ empty class. Middle-end and x86 backend are updated to ignore empty records for parameter passing and function value return. Other targets may need similar changes. get_ref_base_and_extent is changed to set bitsize to 0 for empty records so that when ref_maybe_used_by_call_p_1 calls get_ref_base_and_extent to get 0 as the maximum size on empty record. Otherwise, find_tail_calls won't perform tail call optimization for functions with empty record parameters, as shown in g++.dg/pr60336-1.C and g++.dg/pr60336-2.C. A new cxx target hook, function_skip_empty_class_p, is added, which defaults to return false. This ABI change is enabled only if the ABI level is at least 10, which is updated in GCC 6, and the target hook TARGET_CXX_FUNCTION_SKIP_EMPTY_CLASS_P returns true. gcc/ PR c++/60336 PR middle-end/67239 PR target/68355 * calls.c (initialize_argument_information): Warn empty record if they are used in a variable argument list or aren't the last arguments. Replace targetm.calls.function_arg, targetm.calls.function_incoming_arg and targetm.calls.function_arg_advance with function_arg, function_incoming_arg and function_arg_advance. (expand_call): Replace targetm.calls.function_arg, targetm.calls.function_incoming_arg and targetm.calls.function_arg_advance with function_arg, function_incoming_arg and function_arg_advance. (emit_library_call_value_1): Likewise. (store_one_arg): Use 0 for empty record size. Don't push 0 size argument onto stack. (must_pass_in_stack_var_size_or_pad): Return false for empty record. * dse.c (get_call_args): Replace targetm.calls.function_arg and targetm.calls.function_arg_advance with function_arg and function_arg_advance. * explow.c (hard_function_value): Use 0 for empty record size. * expr.c (block_move_libcall_safe_for_call_parm): Replace targetm.calls.function_arg and targetm.calls.function_arg_advance with function_arg and function_arg_advance. (copy_blkmode_to_reg): Use 0 for empty record size. * function.c (aggregate_value_p): Replace targetm.calls.return_in_memory with return_in_memory. (assign_parm_data_all): Add warn_empty_record. (assign_parms_augmented_arg_list): Set warn_empty_record if empty records are used in a variable argument list or aren't the last arguments. (assign_parm_find_entry_rtl): Warn empty record if warn_empty_record is set. Replace targetm.calls.function_incoming_arg with function_incoming_arg. (assign_parms): Only warn empty record once. Replace targetm.calls.function_arg_advance with function_arg_advance. (gimplify_parameters): Replace targetm.calls.function_arg_advance with function_arg_advance. (locate_and_pad_parm): Use 0 for empty record size. (warn_empty_record): New function. (function_arg_advance): New wrapper function. (function_arg): Likewise. (function_incoming_arg): Likewise. (return_in_memory): Likewise. * lto-streamer-out.c (hash_tree): Call hstate.add_flag with TYPE_EMPTY_RECORD for types. * print-tree.c (print_node): Also handle TYPE_EMPTY_RECORD. * ubsan.c (ubsan_type_descriptor): Likewise. * target.def (cxx): Add function_skip_empty_class_p. * target.h (function_arg_advance): New prototype. (function_arg): Likewise. (function_incoming_arg): Likewise. (return_in_memory): Likewise. * targhooks.c (std_gimplify_va_arg_expr): Use 0 for empty record size. * tree-dfa.c (get_ref_base_and_extent): Likewise. * tree-core.h (tree_base): Mention TYPE_EMPTY_RECORD in comments for side_effects_flag. * tree-streamer-in.c (unpack_ts_base_value_fields): Stream in TYPE_EMPTY_RECORD for types. * tree-streamer-out.c (pack_ts_base_value_fields): Stream out TYPE_EMPTY_RECORD for types. * tree.h (TYPE_EMPTY_RECORD): New. (type_is_empty_record_p): New static inline function. * var-tracking.c (prepare_call_arguments): Replace targetm.calls.function_arg and targetm.calls.function_arg_advance with function_arg and function_arg_advance. * config/i386/i386.c (ix86_gimplify_va_arg): Use 0 for empty record size. (TARGET_CXX_FUNCTION_SKIP_EMPTY_CLASS_P): New hook to return true. * doc/tm.texi.in (TARGET_CXX_FUNCTION_SKIP_EMPTY_CLASS_P): New hook. * doc/tm.texi: Regenerated. gcc/c PR c++/60336 PR middle-end/67239 PR target/68355 * c-aux-info.c (gen_type): Add TYPE_EMPTY_RECORD check. gcc/cp/ PR c++/60336 PR middle-end/67239 PR target/68355 * class.c (is_empty_collection): New function. (is_empty_record): Likewise. (finish_struct_1): Set TYPE_EMPTY_RECORD with return value from is_empty_record () if the ABI level is at least 10. gcc/lto/ PR c++/60336 PR middle-end/67239 PR target/68355 * lto.c (compare_tree_sccs_1): Call compare_values with TYPE_EMPTY_RECORD for types. gcc/testsuite/ PR c++/60336 PR middle-end/67239 PR target/68355 * g++.dg/abi/empty12.C: New test. * g++.dg/abi/empty12.h: Likewise. * g++.dg/abi/empty12a.c: Likewise. * g++.dg/abi/empty13.C: Likewise. * g++.dg/abi/empty13.h: Likewise. * g++.dg/abi/empty13a.c: Likewise. * g++.dg/abi/empty14.C: Likewise. * g++.dg/abi/empty14.h: Likewise. * g++.dg/abi/empty14a.c: Likewise. * g++.dg/abi/empty15.C: Likewise. * g++.dg/abi/empty15.h: Likewise. * g++.dg/abi/empty15a.c: Likewise. * g++.dg/abi/empty16.C: Likewise. * g++.dg/abi/empty16.h: Likewise. * g++.dg/abi/empty16a.c: Likewise. * g++.dg/abi/empty17.C: Likewise. * g++.dg/abi/empty17.h: Likewise. * g++.dg/abi/empty17a.c: Likewise. * g++.dg/pr60336-1.C: Likewise. * g++.dg/pr60336-2.C: Likewise. * g++.dg/pr60336-3.C: Likewise. * g++.dg/pr60336-4.C: Likewise. * g++.dg/pr60336-5.C: Likewise. * g++.dg/pr60336-6.C: Likewise. * g++.dg/pr60336-7.C: Likewise. * g++.dg/pr60336-8.C: Likewise. * g++.dg/pr60336-9.C: Likewise. * g++.dg/pr60336-10.C: Likewise. * g++.dg/pr60336-11.C: Likewise. * g++.dg/pr60336-12.C: Likewise. * g++.dg/pr68355.C: Likewise.
Diffstat (limited to 'gcc/ada/s-vallld.adb')
0 files changed, 0 insertions, 0 deletions