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]

Re: [PATCH] Fix PR27781


On Thu, 15 Jun 2006, Andrew Pinski wrote:

> 
> On Jun 15, 2006, at 8:29 AM, Richard Guenther wrote:
> 
> >
> >2nd try.
> >
> >Bootstrapped and regtested on x86_64-unknown-linux-gnu.
> 
> Again you should use targetm.binds_local_p.

I just attached the wrong patch.  Here's the correct one:

2006-06-16  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27781
	* Makefile.in (ipa-pure-const.o): Add $(TARGET_H) dependency.
	* ipa-pure-const.c (target.h): Include.
	(analyze_function): Only analyze functions that bind locally.

	* gcc.dg/tree-ssa/pr27781.c: New testcase.

Index: Makefile.in
===================================================================
*** Makefile.in	(revision 114674)
--- Makefile.in	(working copy)
*************** ipa-reference.o : ipa-reference.c $(CONF
*** 2309,2315 ****
     $(TREE_GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) tree-pass.h $(DIAGNOSTIC_H)  
  ipa-pure-const.o : ipa-pure-const.c $(CONFIG_H) $(SYSTEM_H) \
     coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
!    pointer-set.h $(GGC_H) $(IPA_UTILS_H) $(C_COMMON_H) \
     $(TREE_GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) tree-pass.h $(DIAGNOSTIC_H)  
  ipa-type-escape.o : ipa-type-escape.c $(CONFIG_H) $(SYSTEM_H) \
     coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
--- 2309,2315 ----
     $(TREE_GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) tree-pass.h $(DIAGNOSTIC_H)  
  ipa-pure-const.o : ipa-pure-const.c $(CONFIG_H) $(SYSTEM_H) \
     coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
!    pointer-set.h $(GGC_H) $(IPA_UTILS_H) $(C_COMMON_H) $(TARGET_H) \
     $(TREE_GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) tree-pass.h $(DIAGNOSTIC_H)  
  ipa-type-escape.o : ipa-type-escape.c $(CONFIG_H) $(SYSTEM_H) \
     coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
Index: ipa-pure-const.c
===================================================================
*** ipa-pure-const.c	(revision 114674)
--- ipa-pure-const.c	(working copy)
*************** Software Foundation, 51 Franklin Street,
*** 51,56 ****
--- 51,57 ----
  #include "timevar.h"
  #include "diagnostic.h"
  #include "langhooks.h"
+ #include "target.h"
  
  static struct pointer_set_t *visited_nodes;
  
*************** 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;
--- 500,508 ----
    l->pure_const_state = IPA_CONST;
    l->state_set_in_source = false;
  
!   /* If this function does not bind locally, do not touch this unless it has
       been marked as const or pure by the front end.  */
!   if (!targetm.binds_local_p (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]