This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR27781, weak functions considered pure/const


This fixes ipa-pure-const by excluding weak functions from the analysis.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.

Ok for mainline/4.1?

Thanks,
Richard.

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" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]