On Tue, Nov 17, 2015 at 4:22 AM, Richard Biener <richard.guent...@gmail.com> wrote: > On Tue, Nov 17, 2015 at 12:01 PM, H.J. Lu <hjl.to...@gmail.com> wrote: >> Empty record should be returned and passed the same way in C and C++. >> This patch adds LANG_HOOKS_EMPTY_RECORD_P for C++ empty class, which >> defaults to return false. For C++, LANG_HOOKS_EMPTY_RECORD_P is defined >> to is_really_empty_class, which returns true for C++ empty classes. For >> LTO, we stream out a bit to indicate if a record is empty and we store >> it in TYPE_LANG_FLAG_0 when streaming in. get_ref_base_and_extent is >> changed to set bitsize to 0 for empty records. Middle-end and x86 >> backend are updated to ignore empty records for parameter passing and >> function value return. Other targets may need similar changes. > > Please avoid a new langhook for this and instead claim a bit in > tree_type_common > like for example restrict_flag (double-check it is unused for non-pointers).
There is no bit in tree_type_common I can overload. restrict_flag is checked for non-pointers to issue an error when it is used on non-pointers: /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/template/qualttp20.C:19:38: error: ‘__restrict__’ qualifiers cannot be applied to ‘AS::L’ typedef typename T::L __restrict__ r;// { dg-error "'__restrict__' qualifiers cannot" "" } Should I add a bit to tree_type_common? It may crease the size of tree_type_common by 4 bytes since there is unused bits in tree_type_common. > I don't like that you need to modify targets - those checks should be done > in the caller (which may just use a new wrapper with the logic and then > dispatching to the actual hook). I can do that. > Why do you need do adjust get_ref_base_and_extent? 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 in struct dummy { }; struct true_type { struct dummy i; }; extern true_type y; extern void xxx (true_type c); void yyy (void) { xxx (y); } -- H.J.