Summary: | [4.0 Regression] set_nothrow_function_flags does invalid analysis on weak functions | ||
---|---|---|---|
Product: | gcc | Reporter: | Jorn Wolfgang Rennecke <amylaar> |
Component: | rtl-optimization | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | andrew.stubbs, fang, gcc-bugs, pinskia, rguenth |
Priority: | P3 | Keywords: | EH, wrong-code |
Version: | 4.2.0 | ||
Target Milestone: | 4.1.2 | ||
Host: | Target: | ||
Build: | Known to work: | 2.95.3 4.1.2 4.2.0 | |
Known to fail: | 4.1.1 4.2.0 3.3.3 3.0.4 | Last reconfirmed: | 2006-10-09 14:25:36 |
Attachments: |
test case - main file
test case - actual definition of function foo |
Description
Jorn Wolfgang Rennecke
2006-10-02 16:05:00 UTC
Created attachment 12370 [details]
test case - main file
Created attachment 12371 [details]
test case - actual definition of function foo
While except.c:set_nothrow_function_flags analyzes rtl, the DECL_NOTHROW flag it computes is a tree bit. via calls.c:flags_from_decl_or_type -> calls.c:call_expr_flags -> tree-eh.c:tree_could_throw_p makes this information is made available to the tree optimizers. http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00354.html So this is a regression from 2.95.3. The frontend marks foo () TREE_STATIC in start_preparsed_function () and later TREE_NOTHROW in finish_function () because /* If this function can't throw any exceptions, remember that. */ if (!processing_template_decl && !cp_function_chain->can_throw && !flag_non_call_exceptions) TREE_NOTHROW (fndecl) = 1; where cp_function_chain->can_throw is 0 (its initial value(?)). Fixing that and the RTL problem fixes the testcase. I am, of course, not sure if the C++ frontend fix is ok. Index: except.c =================================================================== --- except.c (revision 117569) +++ except.c (working copy) @@ -2787,6 +2787,9 @@ set_nothrow_function_flags (void) { rtx insn; + if (!targetm.binds_local_p (current_function_decl)) + return 0; + TREE_NOTHROW (current_function_decl) = 1; /* Assume cfun->all_throwers_are_sibcalls until we encounter Index: cp/decl.c =================================================================== --- cp/decl.c (revision 117569) +++ cp/decl.c (working copy) @@ -11081,7 +11081,8 @@ finish_function (int flags) /* If this function can't throw any exceptions, remember that. */ if (!processing_template_decl && !cp_function_chain->can_throw - && !flag_non_call_exceptions) + && !flag_non_call_exceptions + && targetm.binds_local_p (fndecl)) TREE_NOTHROW (fndecl) = 1; /* This must come after expand_function_end because cleanups might Subject: Bug number PR29323 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00458.html Subject: Bug 29323 Author: rguenth Date: Tue Oct 10 08:27:02 2006 New Revision: 117598 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117598 Log: 2006-10-10 Richard Guenther <rguenther@suse.de> PR rtl-optimization/29323 * except.c (set_nothrow_function_flags): For functions that do not bind local bail out early. * decl.c (finish_function): Set TREE_NOTHROW only for functions that bind local. Modified: trunk/gcc/ChangeLog trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/except.c Fixed on the mainline. Subject: Bug 29323 Author: rguenth Date: Sat Oct 14 09:13:43 2006 New Revision: 117727 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117727 Log: 2006-10-14 Richard Guenther <rguenther@suse.de> PR rtl-optimization/29323 * except.c (set_nothrow_function_flags): For functions that do not bind local bail out early. * decl.c (finish_function): Set TREE_NOTHROW only for functions that bind local. Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/decl.c branches/gcc-4_1-branch/gcc/except.c Fixed for 4.1.2. Fixed in GCC-4.1.2. |