[PATCH] Fix PR27781
Richard Guenther
rguenther@suse.de
Thu Jun 15 15:41:00 GMT 2006
2nd try.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline and 4.1?
Thanks,
Richard.
:ADDPATCH middle-end:
2006-05-28 Richard Guenther <rguenther@suse.de>
PR tree-optimization/27781
* ipa-pure-const.c (analyze_function): Treat weak functions
like volatile ones.
* gcc.dg/tree-ssa/pr27781.c: New testcase.
Index: ipa-pure-const.c
===================================================================
*** ipa-pure-const.c (revision 114166)
--- ipa-pure-const.c (working copy)
*************** analyze_function (struct cgraph_node *fn
*** 499,507 ****
l->pure_const_state = IPA_CONST;
l->state_set_in_source = false;
! /* If this is a volatile function, do not touch this unless it has
been marked as const or pure by the front end. */
! if (TREE_THIS_VOLATILE (decl))
{
l->pure_const_state = IPA_NEITHER;
return;
--- 499,508 ----
l->pure_const_state = IPA_CONST;
l->state_set_in_source = false;
! /* If this is a volatile or weak function, do not touch this unless it has
been marked as const or pure by the front end. */
! if (TREE_THIS_VOLATILE (decl)
! || DECL_WEAK (decl))
{
l->pure_const_state = IPA_NEITHER;
return;
Index: testsuite/gcc.dg/tree-ssa/pr27781.c
===================================================================
*** testsuite/gcc.dg/tree-ssa/pr27781.c (revision 0)
--- testsuite/gcc.dg/tree-ssa/pr27781.c (revision 0)
***************
*** 0 ****
--- 1,16 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -fdump-tree-optimized" } */
+
+ void __attribute__((weak)) func(void)
+ {
+ /* no code */
+ }
+
+ int main()
+ {
+ func();
+ return 0;
+ }
+
+ /* { dg-final { scan-tree-dump "func \\(\\);" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
More information about the Gcc-patches
mailing list