From patchwork Fri Aug 20 13:43:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 62278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C68C3B70CB for ; Fri, 20 Aug 2010 23:43:06 +1000 (EST) Received: (qmail 18268 invoked by alias); 20 Aug 2010 13:43:01 -0000 Received: (qmail 18251 invoked by uid 22791); 20 Aug 2010 13:42:58 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_BG, TW_FN, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Aug 2010 13:42:52 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7KDgoCK030201 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Aug 2010 09:42:50 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7KDgodb025628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 20 Aug 2010 09:42:50 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o7KDhH04004098; Fri, 20 Aug 2010 15:43:17 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o7KDhHiv004096; Fri, 20 Aug 2010 15:43:17 +0200 Date: Fri, 20 Aug 2010 15:43:16 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH] Mark a bunch of fndecls in Fortran FE TREE_NOTHROW Message-ID: <20100820134316.GB702@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! Given that some people apparently compile Fortran code with -fexceptions, it is desirable to pay little bit more attention to TREE_NOTHROW. This patch adds it to a bunch of functions that clearly can't ever throw. The criteria I was using is that it doesn't call any of the IO functions (including os_error and similar, so that rules also libgfortran memory allocations) nor any other function which might throw e.g. on pthread_cancel. Calls to memcpy/memset/strcmp/strncasecmp etc. are ok. One of the routines actually has assert in it, but it is quite obvious when reading the source that the assert can never trigger. Also, I've noticed that ishftc{4,8,16} are actually constant functions too, so it adds TREE_READONLY for those 3 as well. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-08-20 Jakub Jelinek * trans-decl.c (gfc_build_intrinsic_function_decls): Set TREE_NOTHROW on fndecls that can't throw. Set TREE_READONLY on gfor_fndecl_math_ishftc{4,8,16}. (gfc_build_builtin_function_decls): Set TREE_NOTHROW on gfor_fndecl_associated. Jakub --- gcc/fortran/trans-decl.c.jj 2010-08-17 10:32:38.000000000 +0200 +++ gcc/fortran/trans-decl.c 2010-08-20 11:45:06.000000000 +0200 @@ -2427,35 +2427,41 @@ gfc_build_intrinsic_function_decls (void integer_type_node, 4, gfc_charlen_type_node, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node); DECL_PURE_P (gfor_fndecl_compare_string) = 1; + TREE_NOTHROW (gfor_fndecl_compare_string) = 1; gfor_fndecl_concat_string = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("concat_string")), "..W.R.R", void_type_node, 6, gfc_charlen_type_node, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node); + TREE_NOTHROW (gfor_fndecl_concat_string) = 1; gfor_fndecl_string_len_trim = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_len_trim")), "..R", gfc_charlen_type_node, 2, gfc_charlen_type_node, pchar1_type_node); DECL_PURE_P (gfor_fndecl_string_len_trim) = 1; + TREE_NOTHROW (gfor_fndecl_string_len_trim) = 1; gfor_fndecl_string_index = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_index")), "..R.R.", gfc_charlen_type_node, 5, gfc_charlen_type_node, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node, gfc_logical4_type_node); DECL_PURE_P (gfor_fndecl_string_index) = 1; + TREE_NOTHROW (gfor_fndecl_string_index) = 1; gfor_fndecl_string_scan = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_scan")), "..R.R.", gfc_charlen_type_node, 5, gfc_charlen_type_node, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node, gfc_logical4_type_node); DECL_PURE_P (gfor_fndecl_string_scan) = 1; + TREE_NOTHROW (gfor_fndecl_string_scan) = 1; gfor_fndecl_string_verify = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_verify")), "..R.R.", gfc_charlen_type_node, 5, gfc_charlen_type_node, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node, gfc_logical4_type_node); DECL_PURE_P (gfor_fndecl_string_verify) = 1; + TREE_NOTHROW (gfor_fndecl_string_verify) = 1; gfor_fndecl_string_trim = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_trim")), ".Ww.R", @@ -2473,52 +2479,61 @@ gfc_build_intrinsic_function_decls (void get_identifier (PREFIX("adjustl")), ".W.R", void_type_node, 3, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node); + TREE_NOTHROW (gfor_fndecl_adjustl) = 1; gfor_fndecl_adjustr = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("adjustr")), ".W.R", void_type_node, 3, pchar1_type_node, gfc_charlen_type_node, pchar1_type_node); + TREE_NOTHROW (gfor_fndecl_adjustr) = 1; gfor_fndecl_select_string = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("select_string")), ".R.R.", integer_type_node, 4, pvoid_type_node, integer_type_node, pchar1_type_node, gfc_charlen_type_node); DECL_PURE_P (gfor_fndecl_select_string) = 1; + TREE_NOTHROW (gfor_fndecl_select_string) = 1; gfor_fndecl_compare_string_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("compare_string_char4")), "..R.R", integer_type_node, 4, gfc_charlen_type_node, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node); DECL_PURE_P (gfor_fndecl_compare_string_char4) = 1; + TREE_NOTHROW (gfor_fndecl_compare_string_char4) = 1; gfor_fndecl_concat_string_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("concat_string_char4")), "..W.R.R", void_type_node, 6, gfc_charlen_type_node, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node); + TREE_NOTHROW (gfor_fndecl_concat_string_char4) = 1; gfor_fndecl_string_len_trim_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_len_trim_char4")), "..R", gfc_charlen_type_node, 2, gfc_charlen_type_node, pchar4_type_node); DECL_PURE_P (gfor_fndecl_string_len_trim_char4) = 1; + TREE_NOTHROW (gfor_fndecl_string_len_trim_char4) = 1; gfor_fndecl_string_index_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_index_char4")), "..R.R.", gfc_charlen_type_node, 5, gfc_charlen_type_node, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node, gfc_logical4_type_node); DECL_PURE_P (gfor_fndecl_string_index_char4) = 1; + TREE_NOTHROW (gfor_fndecl_string_index_char4) = 1; gfor_fndecl_string_scan_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_scan_char4")), "..R.R.", gfc_charlen_type_node, 5, gfc_charlen_type_node, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node, gfc_logical4_type_node); DECL_PURE_P (gfor_fndecl_string_scan_char4) = 1; + TREE_NOTHROW (gfor_fndecl_string_scan_char4) = 1; gfor_fndecl_string_verify_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_verify_char4")), "..R.R.", gfc_charlen_type_node, 5, gfc_charlen_type_node, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node, gfc_logical4_type_node); DECL_PURE_P (gfor_fndecl_string_verify_char4) = 1; + TREE_NOTHROW (gfor_fndecl_string_verify_char4) = 1; gfor_fndecl_string_trim_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("string_trim_char4")), ".Ww.R", @@ -2536,17 +2551,20 @@ gfc_build_intrinsic_function_decls (void get_identifier (PREFIX("adjustl_char4")), ".W.R", void_type_node, 3, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node); + TREE_NOTHROW (gfor_fndecl_adjustl_char4) = 1; gfor_fndecl_adjustr_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("adjustr_char4")), ".W.R", void_type_node, 3, pchar4_type_node, gfc_charlen_type_node, pchar4_type_node); + TREE_NOTHROW (gfor_fndecl_adjustr_char4) = 1; gfor_fndecl_select_string_char4 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("select_string_char4")), ".R.R.", integer_type_node, 4, pvoid_type_node, integer_type_node, pvoid_type_node, gfc_charlen_type_node); DECL_PURE_P (gfor_fndecl_select_string_char4) = 1; + TREE_NOTHROW (gfor_fndecl_select_string_char4) = 1; /* Conversion between character kinds. */ @@ -2581,17 +2599,20 @@ gfc_build_intrinsic_function_decls (void get_identifier (PREFIX("selected_char_kind")), "..R", gfc_int4_type_node, 2, gfc_charlen_type_node, pchar_type_node); DECL_PURE_P (gfor_fndecl_sc_kind) = 1; + TREE_NOTHROW (gfor_fndecl_sc_kind) = 1; gfor_fndecl_si_kind = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("selected_int_kind")), ".R", gfc_int4_type_node, 1, pvoid_type_node); DECL_PURE_P (gfor_fndecl_si_kind) = 1; + TREE_NOTHROW (gfor_fndecl_si_kind) = 1; gfor_fndecl_sr_kind = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("selected_real_kind2008")), ".RR", gfc_int4_type_node, 3, pvoid_type_node, pvoid_type_node, pvoid_type_node); DECL_PURE_P (gfor_fndecl_sr_kind) = 1; + TREE_NOTHROW (gfor_fndecl_sr_kind) = 1; /* Power functions. */ { @@ -2618,6 +2639,7 @@ gfc_build_intrinsic_function_decls (void gfc_build_library_function_decl (get_identifier (name), jtype, 2, jtype, itype); TREE_READONLY (gfor_fndecl_math_powi[jkind][ikind].integer) = 1; + TREE_NOTHROW (gfor_fndecl_math_powi[jkind][ikind].integer) = 1; } } @@ -2632,6 +2654,7 @@ gfc_build_intrinsic_function_decls (void gfc_build_library_function_decl (get_identifier (name), rtype, 2, rtype, itype); TREE_READONLY (gfor_fndecl_math_powi[rkind][ikind].real) = 1; + TREE_NOTHROW (gfor_fndecl_math_powi[rkind][ikind].real) = 1; } ctype = gfc_get_complex_type (rkinds[rkind]); @@ -2643,6 +2666,7 @@ gfc_build_intrinsic_function_decls (void gfc_build_library_function_decl (get_identifier (name), ctype, 2,ctype, itype); TREE_READONLY (gfor_fndecl_math_powi[rkind][ikind].cmplx) = 1; + TREE_NOTHROW (gfor_fndecl_math_powi[rkind][ikind].cmplx) = 1; } } } @@ -2654,17 +2678,25 @@ gfc_build_intrinsic_function_decls (void get_identifier (PREFIX("ishftc4")), gfc_int4_type_node, 3, gfc_int4_type_node, gfc_int4_type_node, gfc_int4_type_node); + TREE_READONLY (gfor_fndecl_math_ishftc4) = 1; + TREE_NOTHROW (gfor_fndecl_math_ishftc4) = 1; gfor_fndecl_math_ishftc8 = gfc_build_library_function_decl ( get_identifier (PREFIX("ishftc8")), gfc_int8_type_node, 3, gfc_int8_type_node, gfc_int4_type_node, gfc_int4_type_node); + TREE_READONLY (gfor_fndecl_math_ishftc8) = 1; + TREE_NOTHROW (gfor_fndecl_math_ishftc8) = 1; if (gfc_int16_type_node) - gfor_fndecl_math_ishftc16 = gfc_build_library_function_decl ( + { + gfor_fndecl_math_ishftc16 = gfc_build_library_function_decl ( get_identifier (PREFIX("ishftc16")), gfc_int16_type_node, 3, gfc_int16_type_node, gfc_int4_type_node, gfc_int4_type_node); + TREE_READONLY (gfor_fndecl_math_ishftc16) = 1; + TREE_NOTHROW (gfor_fndecl_math_ishftc16) = 1; + } /* BLAS functions. */ { @@ -2714,14 +2746,17 @@ gfc_build_intrinsic_function_decls (void get_identifier (PREFIX("size0")), ".R", gfc_array_index_type, 1, pvoid_type_node); DECL_PURE_P (gfor_fndecl_size0) = 1; + TREE_NOTHROW (gfor_fndecl_size0) = 1; gfor_fndecl_size1 = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("size1")), ".R", gfc_array_index_type, 2, pvoid_type_node, gfc_array_index_type); DECL_PURE_P (gfor_fndecl_size1) = 1; + TREE_NOTHROW (gfor_fndecl_size1) = 1; gfor_fndecl_iargc = gfc_build_library_function_decl ( get_identifier (PREFIX ("iargc")), gfc_int4_type_node, 0); + TREE_NOTHROW (gfor_fndecl_iargc) = 1; if (gfc_type_for_size (128, true)) { @@ -2730,10 +2765,12 @@ gfc_build_intrinsic_function_decls (void gfor_fndecl_clz128 = gfc_build_library_function_decl ( get_identifier (PREFIX ("clz128")), integer_type_node, 1, uint128); TREE_READONLY (gfor_fndecl_clz128) = 1; + TREE_NOTHROW (gfor_fndecl_clz128) = 1; gfor_fndecl_ctz128 = gfc_build_library_function_decl ( get_identifier (PREFIX ("ctz128")), integer_type_node, 1, uint128); TREE_READONLY (gfor_fndecl_ctz128) = 1; + TREE_NOTHROW (gfor_fndecl_ctz128) = 1; } } @@ -2843,6 +2880,7 @@ gfc_build_builtin_function_decls (void) get_identifier (PREFIX("associated")), ".RR", integer_type_node, 2, ppvoid_type_node, ppvoid_type_node); DECL_PURE_P (gfor_fndecl_associated) = 1; + TREE_NOTHROW (gfor_fndecl_associated) = 1; gfc_build_intrinsic_function_decls (); gfc_build_intrinsic_lib_fndecls ();