]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix for devirtualization dump functions
authorMartin Liska <mliska@suse.cz>
Fri, 27 Jun 2014 09:24:45 +0000 (11:24 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 27 Jun 2014 09:24:45 +0000 (09:24 +0000)
        * gimple.h (gimple_location_safe): New function introduced.
* cgraphunit.c (walk_polymorphic_call_targets): Usage
of gimple_location_safe replaces gimple_location.
(gimple_fold_call): Likewise.
* ipa-devirt.c (ipa_devirt): Likewise.
* ipa-prop.c (ipa_make_edge_direct_to_target): Likewise.
* ipa.c (walk_polymorphic_call_targets): Likewise.
* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise.

From-SVN: r212067

gcc/ChangeLog
gcc/cgraphunit.c
gcc/gimple-fold.c
gcc/gimple.h
gcc/ipa-devirt.c
gcc/ipa-prop.c
gcc/ipa.c
gcc/tree-ssa-pre.c

index 42e6908fb63c7de09f8dcfb8db3152cb5f8ba609..9d96c2baf24085a0272f1c96fb6c61937ba94686 100644 (file)
@@ -1,3 +1,14 @@
+2014-06-27  Martin Liska  <mliska@suse.cz>
+
+       * gimple.h (gimple_location_safe): New function introduced.
+       * cgraphunit.c (walk_polymorphic_call_targets): Usage
+       of gimple_location_safe replaces gimple_location.
+       (gimple_fold_call): Likewise.
+       * ipa-devirt.c (ipa_devirt): Likewise.
+       * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise.
+       * ipa.c (walk_polymorphic_call_targets): Likewise.
+       * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise.
+
 2014-06-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/57233
index 76b2fda1d1e40cc4f0767494b3d48702cbce5225..d7e8038ec64e634036c78bb34325348c721a71df 100644 (file)
@@ -906,7 +906,7 @@ walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets,
            }
           if (dump_enabled_p ())
             {
-             location_t locus = gimple_location (edge->call_stmt);
+             location_t locus = gimple_location_safe (edge->call_stmt);
              dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, locus,
                               "devirtualizing call in %s to %s\n",
                               edge->caller->name (), target->name ());
index 403dee707a323c22b7704d9f10abcd9ddea1808d..3dcb57602c6edc5b64b9ef4c2f246ca31aff632b 100644 (file)
@@ -387,7 +387,7 @@ fold_gimple_assign (gimple_stmt_iterator *si)
                      fndecl = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
                    if (dump_enabled_p ())
                      {
-                       location_t loc = gimple_location (stmt);
+                       location_t loc = gimple_location_safe (stmt);
                        dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
                                         "resolving virtual function address "
                                         "reference to function %s\n",
@@ -1131,7 +1131,7 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
              tree lhs = gimple_call_lhs (stmt);
              if (dump_enabled_p ())
                {
-                 location_t loc = gimple_location (stmt);
+                 location_t loc = gimple_location_safe (stmt);
                  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
                                   "folding virtual function call to %s\n",
                                   targets.length () == 1
index ceefbc0890f09fcddaedf48959d75ac7cead6a9d..3dfafc6d7c17d206425f116424dc9a0677fb0af0 100644 (file)
@@ -1501,6 +1501,15 @@ gimple_location (const_gimple g)
   return g->location;
 }
 
+/* Return location information for statement G if g is not NULL.
+   Otherwise, UNKNOWN_LOCATION is returned.  */
+
+static inline location_t
+gimple_location_safe (const_gimple g)
+{
+  return g ? gimple_location (g) : UNKNOWN_LOCATION;
+}
+
 /* Return pointer to location information for statement G.  */
 
 static inline const location_t *
index 21f4f11218f82ad6991a3c8ffb2e59d73f9b64b2..d6b85bf3415b8f75910958cdb3bf97934b4c9f58 100644 (file)
@@ -2080,7 +2080,7 @@ ipa_devirt (void)
              {
                if (dump_enabled_p ())
                   {
-                    location_t locus = gimple_location (e->call_stmt);
+                    location_t locus = gimple_location_safe (e->call_stmt);
                     dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, locus,
                                      "speculatively devirtualizing call in %s/%i to %s/%i\n",
                                      n->name (), n->order,
index 1e10b53b00fbd9d6080d3e946c9565d7df601bbb..68efc77851c9dff40825191382c5faaf0bcb1e6f 100644 (file)
@@ -2673,17 +2673,11 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target)
 
           if (dump_enabled_p ())
            {
-             const char *fmt = "discovered direct call to non-function in %s/%i, "
-                               "making it __builtin_unreachable\n";
-
-             if (ie->call_stmt)
-               {
-                 location_t loc = gimple_location (ie->call_stmt);
-                 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, fmt,
-                                  ie->caller->name (), ie->caller->order);
-               }
-             else if (dump_file)
-               fprintf (dump_file, fmt, ie->caller->name (), ie->caller->order);
+             location_t loc = gimple_location_safe (ie->call_stmt);
+             dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+                              "discovered direct call to non-function in %s/%i, "
+                              "making it __builtin_unreachable\n",
+                              ie->caller->name (), ie->caller->order);
            }
 
          target = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
@@ -2745,18 +2739,11 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target)
      }
   if (dump_enabled_p ())
     {
-      const char *fmt = "converting indirect call in %s to direct call to %s\n";
-
-      if (ie->call_stmt)
-       {
-         location_t loc = gimple_location (ie->call_stmt);
+      location_t loc = gimple_location_safe (ie->call_stmt);
 
-         dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, fmt,
-                          ie->caller->name (), callee->name ());
-
-       }
-      else if (dump_file)
-       fprintf (dump_file, fmt, ie->caller->name (), callee->name ());
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+                      "converting indirect call in %s to direct call to %s\n",
+                      ie->caller->name (), callee->name ());
     }
   ie = cgraph_make_edge_direct (ie, callee);
   es = inline_edge_summary (ie);
index fce2e36174f73230b7882f1ddaeb3ab25caf33ee..76815648d898ce0902df2a5398d25e8a5079858f 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -198,7 +198,7 @@ walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets,
 
          if (dump_enabled_p ())
             {
-              location_t locus = gimple_location (edge->call_stmt);
+              location_t locus = gimple_location_safe (edge->call_stmt);
               dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, locus,
                                "devirtualizing call in %s/%i to %s/%i\n",
                                edge->caller->name (), edge->caller->order,
index 74238decfef3e9599313cc48127ab3bf0f653d4b..d05a40be1ee4a88600c382a409c58453ca402f6b 100644 (file)
@@ -4367,7 +4367,7 @@ eliminate_dom_walker::before_dom_children (basic_block b)
                {
                  if (dump_enabled_p ())
                    {
-                     location_t loc = gimple_location (stmt);
+                     location_t loc = gimple_location_safe (stmt);
                      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
                                       "converting indirect call to "
                                       "function %s\n",