2006-06-16 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Jun 2006 17:23:41 +0000 (17:23 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Jun 2006 17:23:41 +0000 (17:23 +0000)
PR tree-optimization/27781
* Makefile.in (ipa-pure-const.o): Add $(TARGET_H) dependency.
* ipa-pure-const.c (target.h): Include.
(analyze_function): Do not analyze functions that do not
        bind locally.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114681 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/ipa-pure-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr27781.c [new file with mode: 0644]

index 9abc3e8..3fffbff 100644 (file)
@@ -1,3 +1,11 @@
+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): Do not analyze functions that do not
+       bind locally.
+
 2006-06-15  Andrew MacLeod  <amacleod@redhat.com>
        
        PR middle-end/27793
index e358be7..4ffbd55 100644 (file)
@@ -2309,7 +2309,7 @@ ipa-reference.o : ipa-reference.c $(CONFIG_H) $(SYSTEM_H) \
    $(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) \
+   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 079af5e..041cf29 100644 (file)
@@ -51,6 +51,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include "timevar.h"
 #include "diagnostic.h"
 #include "langhooks.h"
+#include "target.h"
 
 static struct pointer_set_t *visited_nodes;
 
@@ -499,9 +500,11 @@ analyze_function (struct cgraph_node *fn)
   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))
+  /* If this function does not return normally or does not bind local,
+     do not touch this unless it has been marked as const or pure by the
+     front end.  */
+  if (TREE_THIS_VOLATILE (decl)
+      || !targetm.binds_local_p (decl))
     {
       l->pure_const_state = IPA_NEITHER;
       return;
index c538d13..6570fe1 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-16  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/27781
+       * gcc.dg/tree-ssa/pr27781.c: New testcase.
+
 2006-06-15  Thomas Koenig <Thomas.Koenig@online.de>
 
        * gfortran.dg/allocate_zerosize_2.f90:  New test case.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr27781.c b/gcc/testsuite/gcc.dg/tree-ssa/pr27781.c
new file mode 100644 (file)
index 0000000..0e1a02a
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { 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" } } */