From patchwork Fri Dec 9 21:44:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: PR/51291: fix -fgnu-tm ICEs on fortran Date: Fri, 09 Dec 2011 11:44:58 -0000 From: Aldy Hernandez X-Patchwork-Id: 130477 Message-Id: <4EE2815A.40608@redhat.com> To: gcc-patches Cc: Richard Henderson Compiling any fortran program with -fgnu-tm currently ICEs because the TM builtins are defined in gtm-builtins.def which are not included (via builtins.def) in the Fotran front-end. Presently, there are no TM extensions for the Fortran language, but it shouldn't ICE. We could error out early during the compilation if -fgnu-tm is passed to the fortran front-end, but I'd rather just ignore the builtin TM initialization if the front-end doesn't define the builtins. Also, __builtin_eh_pointer is currently ECF_TM_PURE which triggers applying the transaction_pure attribute. In Fortran, we don't have the attribute. Either way (erroring out early or my current approach) is fine with me. This is the approach I tested. OK? PR/51291 * tree.c (build_common_builtin_nodes): Do not use TM_PURE attribute unless language has support for TM. * config/i386/i386.c (ix86_init_tm_builtins): Exit gracefully in the absence of TM builtins. Index: tree.c =================================================================== --- tree.c (revision 182028) +++ tree.c (working copy) @@ -9442,6 +9442,7 @@ void build_common_builtin_nodes (void) { tree tmp, ftype; + int ecf_flags; if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY) || !builtin_decl_explicit_p (BUILT_IN_MEMMOVE)) @@ -9594,9 +9595,12 @@ build_common_builtin_nodes (void) its value in the landing pad. */ ftype = build_function_type_list (ptr_type_node, integer_type_node, NULL_TREE); + ecf_flags = ECF_PURE | ECF_NOTHROW | ECF_LEAF; + /* Only use TM_PURE if we we have TM language support. */ + if (builtin_decl_explicit_p (BUILT_IN_TM_LOAD_1)) + ecf_flags |= ECF_TM_PURE; local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER, - "__builtin_eh_pointer", - ECF_PURE | ECF_NOTHROW | ECF_LEAF | ECF_TM_PURE); + "__builtin_eh_pointer", ecf_flags); tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0); ftype = build_function_type_list (tmp, integer_type_node, NULL_TREE); Index: testsuite/gfortran.dg/trans-mem-skel.f90 =================================================================== --- testsuite/gfortran.dg/trans-mem-skel.f90 (revision 0) +++ testsuite/gfortran.dg/trans-mem-skel.f90 (revision 0) @@ -0,0 +1,5 @@ +! { dg-do compile } +! { dg-options "-fgnu-tm" } +program foo + real x +end program foo Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 182028) +++ config/i386/i386.c (working copy) @@ -27023,6 +27023,11 @@ ix86_init_tm_builtins (void) if (!flag_tm) return; + /* If there are no builtins defined, we must be compiling in a + language without trans-mem support. */ + if (!builtin_decl_explicit_p (BUILT_IN_TM_LOAD_1)) + return; + /* Use whatever attributes a normal TM load has. */ decl = builtin_decl_explicit (BUILT_IN_TM_LOAD_1); attrs_load = DECL_ATTRIBUTES (decl);