toplev.c (output_stack_usage): Be prepared for suffixes created by the compiler in...
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 6 Sep 2013 15:28:02 +0000 (15:28 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 6 Sep 2013 15:28:02 +0000 (15:28 +0000)
* toplev.c (output_stack_usage): Be prepared for suffixes created by
the compiler in the function names.

From-SVN: r202339

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/stack_usage2.adb [new file with mode: 0644]
gcc/toplev.c

index 21c36b6f7815659fef5bb6f211c3d6577cdd2a40..cbaf4c40f9920d2f7b0bd998709d40a2b23ae136 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-06  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * toplev.c (output_stack_usage): Be prepared for suffixes created by
+       the compiler in the function names.
+
 2013-09-06  Jan Hubicka  <jh@suse.cz>
 
        PR middle-end/58094
@@ -8,8 +13,8 @@
 
 2013-09-06  Jan Hubicka  <jh@suse.cz>
 
-       * i386.c (ix86_hard_regno_mode_ok): AVX modes are valid only when       
-       AVX is enabled.
+       * config/i386/i386.c (ix86_hard_regno_mode_ok): AVX modes are valid
+       only when AVX is enabled.
 
 2013-09-06  James Greenhalgh  <james.greenhalgh@arm.com>
 
index 69a4af7df566f2329b5a8eef815d350ea38f351f..b51e5cef988b0592fac54d7aac1d09ec562b2548 100644 (file)
@@ -1,3 +1,7 @@
+2013-09-06  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/stack_usage2.adb: New test.
+
 2013-09-06  James Greenhalgh  <james.greenhalgh@arm.com>
 
        * gcc.target/aarch64/table-intrinsics.c
diff --git a/gcc/testsuite/gnat.dg/stack_usage2.adb b/gcc/testsuite/gnat.dg/stack_usage2.adb
new file mode 100644 (file)
index 0000000..d458a92
--- /dev/null
@@ -0,0 +1,26 @@
+-- { dg-do compile }
+-- { dg-options "-O2 -fstack-usage" }
+
+with System;
+
+procedure Stack_Usage2 is
+
+   Sink : System.Address;
+   pragma Import (Ada, Sink);
+
+   procedure Transmit_Data (Branch : Integer) is
+      pragma No_Inline (Transmit_Data);
+      X : Integer;
+   begin
+      case Branch is
+         when 1 => Sink := X'Address;
+         when others => null;
+      end case;
+   end;
+
+begin
+   Transmit_Data (Branch => 1);
+end;
+
+-- { dg-final { scan-stack-usage-not ":Constprop" } }
+-- { dg-final { cleanup-stack-usage } }
index 4d12bc9246fe92e83e666b2bc40044513dfe71ba..3473211efb15aca25feb757eabd8fa99329bb193 100644 (file)
@@ -1017,22 +1017,35 @@ output_stack_usage (void)
     {
       expanded_location loc
        = expand_location (DECL_SOURCE_LOCATION (current_function_decl));
-      const char *raw_id, *id;
-
-      /* Strip the scope prefix if any.  */
-      raw_id = lang_hooks.decl_printable_name (current_function_decl, 2);
-      id = strrchr (raw_id, '.');
-      if (id)
-       id++;
+      /* We don't want to print the full qualified name because it can be long,
+        so we strip the scope prefix, but we may need to deal with the suffix
+        created by the compiler.  */
+      const char *suffix
+       = strchr (IDENTIFIER_POINTER (DECL_NAME (current_function_decl)), '.');
+      const char *name
+       = lang_hooks.decl_printable_name (current_function_decl, 2);
+      if (suffix)
+       {
+         const char *dot = strchr (name, '.');
+         while (dot && strcasecmp (dot, suffix) != 0)
+           {
+             name = dot + 1;
+             dot = strchr (name, '.');
+           }
+       }
       else
-       id = raw_id;
+       {
+         const char *dot = strrchr (name, '.');
+         if (dot)
+           name = dot + 1;
+       }
 
       fprintf (stack_usage_file,
               "%s:%d:%d:%s\t"HOST_WIDE_INT_PRINT_DEC"\t%s\n",
               lbasename (loc.file),
               loc.line,
               loc.column,
-              id,
+              name,
               stack_usage,
               stack_usage_kind_str[stack_usage_kind]);
     }