On Mon, Oct 14, 2013 at 1:21 PM, Andreas Krebbel <kreb...@linux.vnet.ibm.com> wrote: > On 14/10/13 12:14, Jakub Jelinek wrote: >> On Mon, Oct 14, 2013 at 12:07:00PM +0200, Richard Biener wrote: >>>> htm-nofloat-2.c fails with that patch. The returns-twice flag on >>>> tbegin prevents several optimizations on the cfg and basically >>>> disables the TX optimization in s390_optimize_nonescaping_tx that way. >>>> I'll try to address this with a follow-on patch. >>>> >>>> Ok for mainline and 4.8? >>> >>> I don't see what's special about s390 so that the attributes are only >>> required there. In fact they look valid generally, so no need for the >>> new target hook. >> >> Well, the builtins are machine specific. But, why don't you just >> add the attributes to the builtins when you register them in the backend? >> You are calling add_builtin_function with NULL_TREE attrs, just pass >> the right attribute list and there won't be a need for an extra target hook. > > I somehow couldn't get it working with the add_builtin_function parameter. > Perhaps because these > attrs are supposed to be translated into the respective tree flags > (DECL_IS_RETURNS_TWICE) at that > point already?!
Yes, via handle_..._attribute. > But the following seems to work fine: Looks good. Richard. > --- > gcc/config/s390/s390.c | 39 +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > 1 file changed, 1 insertion(+), 38 modifications(!) > > Index: gcc/config/s390/s390.c > =================================================================== > *** gcc/config/s390/s390.c.orig > --- gcc/config/s390/s390.c > *************** static void > *** 9900,9905 **** > --- 9900,9906 ---- > s390_init_builtins (void) > { > tree ftype, uint64_type; > + tree decl; > > /* void foo (void) */ > ftype = build_function_type_list (void_type_node, NULL_TREE); > *************** s390_init_builtins (void) > *** 9909,9938 **** > /* void foo (int) */ > ftype = build_function_type_list (void_type_node, integer_type_node, > NULL_TREE); > ! add_builtin_function ("__builtin_tabort", ftype, > ! S390_BUILTIN_TABORT, BUILT_IN_MD, NULL, NULL_TREE); > add_builtin_function ("__builtin_tx_assist", ftype, > S390_BUILTIN_TX_ASSIST, BUILT_IN_MD, NULL, NULL_TREE); > > /* int foo (void *) */ > ftype = build_function_type_list (integer_type_node, ptr_type_node, > NULL_TREE); > ! add_builtin_function ("__builtin_tbegin", ftype, S390_BUILTIN_TBEGIN, > ! BUILT_IN_MD, NULL, NULL_TREE); > ! add_builtin_function ("__builtin_tbegin_nofloat", ftype, > ! S390_BUILTIN_TBEGIN_NOFLOAT, > ! BUILT_IN_MD, NULL, NULL_TREE); > > /* int foo (void *, int) */ > ftype = build_function_type_list (integer_type_node, ptr_type_node, > integer_type_node, NULL_TREE); > ! add_builtin_function ("__builtin_tbegin_retry", ftype, > ! S390_BUILTIN_TBEGIN_RETRY, > ! BUILT_IN_MD, > ! NULL, NULL_TREE); > ! add_builtin_function ("__builtin_tbegin_retry_nofloat", ftype, > ! S390_BUILTIN_TBEGIN_RETRY_NOFLOAT, > ! BUILT_IN_MD, > ! NULL, NULL_TREE); > > /* int foo (void) */ > ftype = build_function_type_list (integer_type_node, NULL_TREE); > --- 9910,9947 ---- > /* void foo (int) */ > ftype = build_function_type_list (void_type_node, integer_type_node, > NULL_TREE); > ! decl = add_builtin_function ("__builtin_tabort", ftype, > ! S390_BUILTIN_TABORT, BUILT_IN_MD, NULL, > NULL_TREE); > ! set_call_expr_flags (decl, ECF_NORETURN); > ! > add_builtin_function ("__builtin_tx_assist", ftype, > S390_BUILTIN_TX_ASSIST, BUILT_IN_MD, NULL, NULL_TREE); > > /* int foo (void *) */ > ftype = build_function_type_list (integer_type_node, ptr_type_node, > NULL_TREE); > ! decl = add_builtin_function ("__builtin_tbegin", ftype, > S390_BUILTIN_TBEGIN, > ! BUILT_IN_MD, NULL, NULL_TREE); > ! set_call_expr_flags (decl, ECF_RETURNS_TWICE); > ! > ! decl = add_builtin_function ("__builtin_tbegin_nofloat", ftype, > ! S390_BUILTIN_TBEGIN_NOFLOAT, > ! BUILT_IN_MD, NULL, NULL_TREE); > ! set_call_expr_flags (decl, ECF_RETURNS_TWICE); > > /* int foo (void *, int) */ > ftype = build_function_type_list (integer_type_node, ptr_type_node, > integer_type_node, NULL_TREE); > ! decl = add_builtin_function ("__builtin_tbegin_retry", ftype, > ! S390_BUILTIN_TBEGIN_RETRY, > ! BUILT_IN_MD, > ! NULL, NULL_TREE); > ! set_call_expr_flags (decl, ECF_RETURNS_TWICE); > ! > ! decl = add_builtin_function ("__builtin_tbegin_retry_nofloat", ftype, > ! S390_BUILTIN_TBEGIN_RETRY_NOFLOAT, > ! BUILT_IN_MD, > ! NULL, NULL_TREE); > ! set_call_expr_flags (decl, ECF_RETURNS_TWICE); > > /* int foo (void) */ > ftype = build_function_type_list (integer_type_node, NULL_TREE); >