builtins.c (expand_movstr): Update a call to fold_builtin_strcpy.
authorKazu Hirata <kazu@cs.umass.edu>
Wed, 16 Mar 2005 14:45:15 +0000 (14:45 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Wed, 16 Mar 2005 14:45:15 +0000 (14:45 +0000)
* builtins.c (expand_movstr): Update a call to
fold_builtin_strcpy.
(expand_builtin_strncpy): Update a call to
fold_builtin_strncpy.
(fold_builtin_strcpy, fold_builtin_strncpy): Take decomosed
arguments of CALL_EXPR.
(fold_builtin_1): Update calls to fold_builtin_strcpy and
fold_builtin_strncpy.
* tree-ssa-ccp.c (ccp_fold_builtin): Likewise.
* tree.h: Update the prototypes of fold_builtin_strcpy and
fold_builtin_strncpy.

From-SVN: r96555

gcc/ChangeLog
gcc/builtins.c
gcc/tree-ssa-ccp.c
gcc/tree.h

index 7c520a274f49d8d6d9e6355cf4c4e2a26983c684..36a5e8de52a257c347680aa40527f4667b79d602 100644 (file)
@@ -1,3 +1,17 @@
+2005-03-16  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * builtins.c (expand_movstr): Update a call to
+       fold_builtin_strcpy.
+       (expand_builtin_strncpy): Update a call to
+       fold_builtin_strncpy.
+       (fold_builtin_strcpy, fold_builtin_strncpy): Take decomosed
+       arguments of CALL_EXPR.
+       (fold_builtin_1): Update calls to fold_builtin_strcpy and
+       fold_builtin_strncpy.
+       * tree-ssa-ccp.c (ccp_fold_builtin): Likewise.
+       * tree.h: Update the prototypes of fold_builtin_strcpy and
+       fold_builtin_strncpy.
+
 2005-03-16  Steven Bosscher  <stevenb@suse.de>
             Dorit Naishlos  <dorit@il.ibm.com>
 
index c00fe1c6357027f772a2728d34ae9d668d9e59a3..43f16fc04ebe623036ba646a9dbf3b10c576ec26 100644 (file)
@@ -2942,10 +2942,11 @@ expand_movstr (tree dest, tree src, rtx target, int endp)
 static rtx
 expand_builtin_strcpy (tree exp, rtx target, enum machine_mode mode)
 {
+  tree fndecl = get_callee_fndecl (exp);
   tree arglist = TREE_OPERAND (exp, 1);
   if (validate_arglist (arglist, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
     {
-      tree result = fold_builtin_strcpy (exp, 0);
+      tree result = fold_builtin_strcpy (fndecl, arglist, 0);
       if (result)
        return expand_expr (result, target, mode, EXPAND_NORMAL);
 
@@ -3062,13 +3063,14 @@ builtin_strncpy_read_str (void *data, HOST_WIDE_INT offset,
 static rtx
 expand_builtin_strncpy (tree exp, rtx target, enum machine_mode mode)
 {
+  tree fndecl = get_callee_fndecl (exp);
   tree arglist = TREE_OPERAND (exp, 1);
   if (validate_arglist (arglist,
                        POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
     {
       tree slen = c_strlen (TREE_VALUE (TREE_CHAIN (arglist)), 1);
       tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
-      tree result = fold_builtin_strncpy (exp, slen);
+      tree result = fold_builtin_strncpy (fndecl, arglist, slen);
       
       if (result)
        return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -7254,10 +7256,8 @@ fold_builtin_memmove (tree arglist, tree type)
    simplification can be made.  */
 
 tree
-fold_builtin_strcpy (tree exp, tree len)
+fold_builtin_strcpy (tree fndecl, tree arglist, tree len)
 {
-  tree fndecl = get_callee_fndecl (exp);
-  tree arglist = TREE_OPERAND (exp, 1);
   tree dest, src, fn;
 
   if (!validate_arglist (arglist,
@@ -7298,10 +7298,8 @@ fold_builtin_strcpy (tree exp, tree len)
    can be made.  */
 
 tree
-fold_builtin_strncpy (tree exp, tree slen)
+fold_builtin_strncpy (tree fndecl, tree arglist, tree slen)
 {
-  tree fndecl = get_callee_fndecl (exp);
-  tree arglist = TREE_OPERAND (exp, 1);
   tree dest, src, len, fn;
 
   if (!validate_arglist (arglist,
@@ -8003,10 +8001,10 @@ fold_builtin_1 (tree exp, bool ignore)
       return fold_builtin_strrchr (arglist, type);
 
     case BUILT_IN_STRCPY:
-      return fold_builtin_strcpy (exp, NULL_TREE);
+      return fold_builtin_strcpy (fndecl, arglist, NULL_TREE);
 
     case BUILT_IN_STRNCPY:
-      return fold_builtin_strncpy (exp, NULL_TREE);
+      return fold_builtin_strncpy (fndecl, arglist, NULL_TREE);
 
     case BUILT_IN_STRCMP:
       return fold_builtin_strcmp (arglist);
index b255020917f73edcad366dc1d9850a6dcb319d3f..a14cf7f366485f4b22c5b117e1e8a39164df27cb 100644 (file)
@@ -1999,12 +1999,20 @@ ccp_fold_builtin (tree stmt, tree fn)
 
     case BUILT_IN_STRCPY:
       if (strlen_val[1] && is_gimple_val (strlen_val[1]))
-        result = fold_builtin_strcpy (fn, strlen_val[1]);
+       {
+         tree fndecl = get_callee_fndecl (fn);
+         tree arglist = TREE_OPERAND (fn, 1);
+         result = fold_builtin_strcpy (fndecl, arglist, strlen_val[1]);
+       }
       break;
 
     case BUILT_IN_STRNCPY:
       if (strlen_val[1] && is_gimple_val (strlen_val[1]))
-       result = fold_builtin_strncpy (fn, strlen_val[1]);
+       {
+         tree fndecl = get_callee_fndecl (fn);
+         tree arglist = TREE_OPERAND (fn, 1);
+         result = fold_builtin_strncpy (fndecl, arglist, strlen_val[1]);
+       }
       break;
 
     case BUILT_IN_FPUTS:
index 8854b7df8fdff3b38bb92dfc03a80ae921c2bbd5..1fd1ab6e44b6759d5ca6c29ee33ae24b5e0625b0 100644 (file)
@@ -3565,8 +3565,8 @@ extern bool ptr_difference_const (tree, tree, HOST_WIDE_INT *);
 /* In builtins.c */
 extern tree fold_builtin (tree, bool);
 extern tree fold_builtin_fputs (tree, bool, bool, tree);
-extern tree fold_builtin_strcpy (tree, tree);
-extern tree fold_builtin_strncpy (tree, tree);
+extern tree fold_builtin_strcpy (tree, tree, tree);
+extern tree fold_builtin_strncpy (tree, tree, tree);
 extern bool fold_builtin_next_arg (tree);
 extern enum built_in_function builtin_mathfn_code (tree);
 extern tree build_function_call_expr (tree, tree);