OSDN Git Service

2011-04-08 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Apr 2011 12:19:45 +0000 (12:19 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Apr 2011 12:19:45 +0000 (12:19 +0000)
* gimple.h (gimple_call_fntype): New function.
(gimple_call_return_type): Use it.
* expr.c (expand_expr_real_1): Use gimple_call_fntype.
* gimple-low.c (gimple_check_call_args): Likewise.
* gimple.c (gimple_call_flags): Likewise.
(gimple_call_arg_flags): Likewise.
(gimple_call_return_flags): Likewise.
* tree-cfg.c (verify_gimple_call): Likewise.
(do_warn_unused_result): Likewise.
* tree-ssa-ccp.c (ccp_fold_stmt): Likewise.
* value-prof.c (gimple_ic_transform): Fix fndecl check.

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

gcc/ChangeLog
gcc/expr.c
gcc/gimple-low.c
gcc/gimple.c
gcc/gimple.h
gcc/tree-cfg.c
gcc/tree-ssa-ccp.c
gcc/value-prof.c

index 75ebe6f..0372c2f 100644 (file)
@@ -1,3 +1,17 @@
+2011-04-08  Richard Guenther  <rguenther@suse.de>
+
+       * gimple.h (gimple_call_fntype): New function.
+       (gimple_call_return_type): Use it.
+       * expr.c (expand_expr_real_1): Use gimple_call_fntype.
+       * gimple-low.c (gimple_check_call_args): Likewise.
+       * gimple.c (gimple_call_flags): Likewise.
+       (gimple_call_arg_flags): Likewise.
+       (gimple_call_return_flags): Likewise.
+       * tree-cfg.c (verify_gimple_call): Likewise.
+       (do_warn_unused_result): Likewise.
+       * tree-ssa-ccp.c (ccp_fold_stmt): Likewise.
+       * value-prof.c (gimple_ic_transform): Fix fndecl check.
+
 2011-04-08  Dmitry Melnik  <dm@ispras.ru>
 
        PR rtl-optimization/48235
index d521f64..6dc4566 100644 (file)
@@ -8533,8 +8533,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
              && (g = SSA_NAME_DEF_STMT (ssa_name))
              && gimple_code (g) == GIMPLE_CALL)
            pmode = promote_function_mode (type, mode, &unsignedp,
-                                          TREE_TYPE
-                                          (TREE_TYPE (gimple_call_fn (g))),
+                                          gimple_call_fntype (g),
                                           2);
          else
            pmode = promote_decl_mode (exp, &unsignedp);
index 9d77442..9968493 100644 (file)
@@ -222,11 +222,10 @@ gimple_check_call_args (gimple stmt)
 
   /* Get argument types for verification.  */
   fndecl = gimple_call_fndecl (stmt);
-  parms = NULL_TREE;
   if (fndecl)
     parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
-  else if (POINTER_TYPE_P (TREE_TYPE (gimple_call_fn (stmt))))
-    parms = TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt))));
+  else
+    parms = TYPE_ARG_TYPES (gimple_call_fntype (stmt));
 
   /* Verify if the type of the argument matches that of the function
      declaration.  If we cannot verify this or there is a mismatch,
index 8881aaa..4675d14 100644 (file)
@@ -1780,15 +1780,17 @@ gimple_call_flags (const_gimple stmt)
 {
   int flags;
   tree decl = gimple_call_fndecl (stmt);
-  tree t;
 
   if (decl)
     flags = flags_from_decl_or_type (decl);
   else
     {
-      t = TREE_TYPE (gimple_call_fn (stmt));
-      if (t && TREE_CODE (t) == POINTER_TYPE)
-       flags = flags_from_decl_or_type (TREE_TYPE (t));
+      tree t = TREE_TYPE (gimple_call_fn (stmt));
+      /* ???  We can end up being called from gimple_set_modified from
+         gsi_remove in which case the function being called can
+        be a released SSA name.  Give up in that case.  */
+      if (t)
+       flags = flags_from_decl_or_type (gimple_call_fntype (stmt));
       else
        flags = 0;
     }
@@ -1804,7 +1806,7 @@ gimple_call_flags (const_gimple stmt)
 int
 gimple_call_arg_flags (const_gimple stmt, unsigned arg)
 {
-  tree type = TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt)));
+  tree type = gimple_call_fntype (stmt);
   tree attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
   if (!attr)
     return 0;
@@ -1848,7 +1850,7 @@ gimple_call_return_flags (const_gimple stmt)
   if (gimple_call_flags (stmt) & ECF_MALLOC)
     return ERF_NOALIAS;
 
-  type = TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt)));
+  type = gimple_call_fntype (stmt);
   attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
   if (!attr)
     return 0;
index cc35b60..be45e4b 100644 (file)
@@ -2011,6 +2011,13 @@ gimple_call_fn (const_gimple gs)
   return gimple_op (gs, 1);
 }
 
+/* Return the function type of the function called by GS.  */
+
+static inline tree
+gimple_call_fntype (const_gimple gs)
+{
+  return TREE_TYPE (TREE_TYPE (gimple_call_fn (gs)));
+}
 
 /* Return a pointer to the tree node representing the function called by call
    statement GS.  */
@@ -2073,13 +2080,9 @@ gimple_call_fndecl (const_gimple gs)
 static inline tree
 gimple_call_return_type (const_gimple gs)
 {
-  tree fn = gimple_call_fn (gs);
-  tree type = TREE_TYPE (fn);
-
-  /* See through the pointer.  */
-  type = TREE_TYPE (type);
+  tree type = gimple_call_fntype (gs);
 
-  /* The type returned by a FUNCTION_DECL is the type of its
+  /* The type returned by a function is the type of its
      function type.  */
   return TREE_TYPE (type);
 }
index e6dac6f..fc8c940 100644 (file)
@@ -3086,7 +3086,7 @@ verify_gimple_call (gimple stmt)
       return true;
     }
 
-  fntype = TREE_TYPE (TREE_TYPE (fn));
+  fntype = gimple_call_fntype (stmt);
   if (gimple_call_lhs (stmt)
       && !useless_type_conversion_p (TREE_TYPE (gimple_call_lhs (stmt)),
                                     TREE_TYPE (fntype))
@@ -7441,7 +7441,7 @@ do_warn_unused_result (gimple_seq seq)
             LHS.  All calls whose value is ignored should be
             represented like this.  Look for the attribute.  */
          fdecl = gimple_call_fndecl (g);
-         ftype = TREE_TYPE (TREE_TYPE (gimple_call_fn (g)));
+         ftype = gimple_call_fntype (g);
 
          if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (ftype)))
            {
index 059274a..4775a2a 100644 (file)
@@ -1727,7 +1727,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
           this can use the argument slot types for type verification
           instead of the current argument type.  We also can safely
           drop qualifiers here as we are dealing with constants anyway.  */
-       argt = TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (gimple_call_fn (stmt))));
+       argt = TYPE_ARG_TYPES (gimple_call_fntype (stmt));
        for (i = 0; i < gimple_call_num_args (stmt) && argt;
             ++i, argt = TREE_CHAIN (argt))
          {
index 8491c77..71e889d 100644 (file)
@@ -1230,16 +1230,13 @@ gimple_ic_transform (gimple stmt)
   histogram_value histogram;
   gcov_type val, count, all, bb_all;
   gcov_type prob;
-  tree callee;
   gimple modify;
   struct cgraph_node *direct_call;
 
   if (gimple_code (stmt) != GIMPLE_CALL)
     return false;
 
-  callee = gimple_call_fn (stmt);
-
-  if (TREE_CODE (callee) == FUNCTION_DECL)
+  if (gimple_call_fndecl (stmt) != NULL_TREE)
     return false;
 
   histogram = gimple_histogram_value_of_type (cfun, stmt, HIST_TYPE_INDIR_CALL);