Handle assembler name in -fdisable/enable options
authorXinliang David Li <davidxl@google.com>
Tue, 7 Jun 2011 19:13:09 +0000 (19:13 +0000)
committerXinliang David Li <davidxl@gcc.gnu.org>
Tue, 7 Jun 2011 19:13:09 +0000 (19:13 +0000)
From-SVN: r174762

12 files changed:
gcc/ChangeLog
gcc/doc/invoke.texi
gcc/passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/inline_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/inline_2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/inline_3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/inline_4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/unroll_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/unroll_2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/unroll_3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/unroll_4.c [new file with mode: 0644]

index 1986a88926385cd849aac3563cb785691b0d11ae..98bda5ce8730b58912c64a0b87dd621bbae96991 100644 (file)
@@ -1,3 +1,7 @@
+2011-06-07  Xinliang David Li  <davidxl@google.com>
+       * passes.c (enable_disable_pass): Handle assembler name.
+       (is_pass_explicitly_enabled_or_disabled): Ditto.
+
 2011-06-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR tree-optimization/48497
index a0690426fd15b54f8a558a0a200b72f244ff544b..5f4c66a1dc161ce7c59327de466fa0542a082c04 100644 (file)
@@ -5065,11 +5065,12 @@ appended with a sequential number starting from 1.
 Disable rtl pass @var{pass}.  @var{pass} is the pass name.  If the same pass is
 statically invoked in the compiler multiple times, the pass name should be
 appended with a sequential number starting from 1.  @var{range-list} is a comma
-seperated list of function ranges.  Each range is a number pair seperated by a colon.
-The range is inclusive in both ends.  If the range is trivial, the number pair can be
-simplified a a single number.  If the function's cgraph node's @var{uid} is falling
-within one of the specified ranges, the @var{pass} is disabled for that function.
-The @var{uid} is shown in the function header of a dump file.
+seperated list of function ranges or assembler names.  Each range is a number
+pair seperated by a colon.  The range is inclusive in both ends.  If the range
+is trivial, the number pair can be simplified as a single number.  If the
+function's cgraph node's @var{uid} is falling within one of the specified ranges,
+the @var{pass} is disabled for that function.  The @var{uid} is shown in the
+function header of a dump file.
 
 @item -fdisable-tree-@var{pass}
 @item -fdisable-tree-@var{pass}=@var{range-list}
@@ -5099,7 +5100,8 @@ of option arguments.
    -fenable-tree-cunroll=1
 # disable gcse2 for functions at the following ranges [1,1],
 # [300,400], and [400,1000]
-   -fdisable-rtl-gcse2=1:100,300,400:1000
+# disable gcse2 for functions foo and foo2
+   -fdisable-rtl-gcse2=foo,foo2
 # disable early inlining
    -fdisable-tree-einline
 # disable ipa inlining
index 9f328cd2fc5901ec9f186e9d218ed560707bcbc8..f06a67c4d90d6a6f0cc60279e37e13c2ae30a40d 100644 (file)
@@ -531,6 +531,7 @@ struct uid_range
 {
   unsigned int start;
   unsigned int last;
+  const char *assem_name;
   struct uid_range *next;
 };
 
@@ -542,6 +543,7 @@ DEF_VEC_ALLOC_P(uid_range_p, heap);
 static VEC(uid_range_p, heap) *enabled_pass_uid_range_tab = NULL;
 static VEC(uid_range_p, heap) *disabled_pass_uid_range_tab = NULL;
 
+
 /* Parse option string for -fdisable- and -fenable-
    The syntax of the options:
 
@@ -628,6 +630,7 @@ enable_disable_pass (const char *arg, bool is_enable)
          uid_range_p new_range;
          char *invalid = NULL;
          long start;
+         char *func_name = NULL;
 
          next_range = strchr (one_range, ',');
          if (next_range)
@@ -645,17 +648,31 @@ enable_disable_pass (const char *arg, bool is_enable)
          start = strtol (one_range, &invalid, 10);
          if (*invalid || start < 0)
            {
-             error ("Invalid range %s in option %s",
-                    one_range,
-                    is_enable ? "-fenable" : "-fdisable");
-             free (argstr);
-             return;
+              if (end_val || (one_range[0] >= '0'
+                             && one_range[0] <= '9'))
+                {
+                  error ("Invalid range %s in option %s",
+                         one_range,
+                         is_enable ? "-fenable" : "-fdisable");
+                  free (argstr);
+                  return;
+                }
+             func_name = one_range;
            }
          if (!end_val)
            {
              new_range = XCNEW (struct uid_range);
-             new_range->start = (unsigned) start;
-             new_range->last = (unsigned) start;
+              if (!func_name)
+                {
+                  new_range->start = (unsigned) start;
+                  new_range->last = (unsigned) start;
+                }
+              else
+                {
+                  new_range->start = (unsigned) -1;
+                  new_range->last = (unsigned) -1;
+                  new_range->assem_name = xstrdup (func_name);
+                }
            }
          else
            {
@@ -677,15 +694,28 @@ enable_disable_pass (const char *arg, bool is_enable)
           new_range->next = slot;
           VEC_replace (uid_range_p, *tab, pass->static_pass_number,
                        new_range);
-
           if (is_enable)
-            inform (UNKNOWN_LOCATION,
-                    "enable pass %s for functions in the range of [%u, %u]",
-                    phase_name, new_range->start, new_range->last);
+            {
+              if (new_range->assem_name)
+                inform (UNKNOWN_LOCATION,
+                        "enable pass %s for function %s",
+                        phase_name, new_range->assem_name);
+              else
+                inform (UNKNOWN_LOCATION,
+                        "enable pass %s for functions in the range of [%u, %u]",
+                        phase_name, new_range->start, new_range->last);
+            }
           else
-            inform (UNKNOWN_LOCATION,
-                    "disable pass %s for functions in the range of [%u, %u]",
-                    phase_name, new_range->start, new_range->last);
+            {
+              if (new_range->assem_name)
+                inform (UNKNOWN_LOCATION,
+                        "disable pass %s for function %s",
+                        phase_name, new_range->assem_name);
+              else
+                inform (UNKNOWN_LOCATION,
+                        "disable pass %s for functions in the range of [%u, %u]",
+                        phase_name, new_range->start, new_range->last);
+            }
 
          one_range = next_range;
        } while (next_range);
@@ -719,6 +749,7 @@ is_pass_explicitly_enabled_or_disabled (struct opt_pass *pass,
 {
   uid_range_p slot, range;
   int cgraph_uid;
+  const char *aname = NULL;
 
   if (!tab
       || (unsigned) pass->static_pass_number >= VEC_length (uid_range_p, tab)
@@ -730,6 +761,8 @@ is_pass_explicitly_enabled_or_disabled (struct opt_pass *pass,
     return false;
 
   cgraph_uid = func ? cgraph_get_node (func)->uid : 0;
+  if (func && DECL_ASSEMBLER_NAME_SET_P (func))
+    aname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func));
 
   range = slot;
   while (range)
@@ -737,6 +770,9 @@ is_pass_explicitly_enabled_or_disabled (struct opt_pass *pass,
       if ((unsigned) cgraph_uid >= range->start
          && (unsigned) cgraph_uid <= range->last)
        return true;
+      if (range->assem_name && aname
+          && !strcmp (range->assem_name, aname))
+        return true;
       range = range->next;
     }
 
index 1372638aef83ec85a344e85be7bc2cf2f0ce18bd..ba89a31f9a8aa620942613fcf20fd3454c52ebec 100644 (file)
@@ -1,3 +1,14 @@
+2011-06-07  Xinliang David Li  <davidxl@google.com>
+
+       * testsuite/gcc.dg/inline_2.c: New test.
+       * testsuite/gcc.dg/unroll_2.c: New test.
+       * testsuite/gcc.dg/inline_3.c: New test.
+       * testsuite/gcc.dg/unroll_3.c: New test.
+       * testsuite/gcc.dg/inline_4.c: New test.
+       * testsuite/gcc.dg/unroll_4.c: New test.
+       * testsuite/gcc.dg/inline_1.c: New test.
+       * testsuite/gcc.dg/unroll_1.c: New test.
+
 2011-06-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        gcc/testsuite:
diff --git a/gcc/testsuite/gcc.dg/inline_1.c b/gcc/testsuite/gcc.dg/inline_1.c
new file mode 100644 (file)
index 0000000..08ccb86
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline -fdisable-ipa-inline" } */
+int g;
+__attribute__((always_inline)) void bar (void)
+{
+  g++;
+}
+
+int foo (void)
+{
+  bar ();
+  return g;
+}
+
+int foo2 (void)
+{
+  bar();
+  return g + 1;
+}
+
+/* { dg-final { scan-tree-dump-times "bar" 5 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+/* { dg-excess-errors "extra notes" } */
diff --git a/gcc/testsuite/gcc.dg/inline_2.c b/gcc/testsuite/gcc.dg/inline_2.c
new file mode 100644 (file)
index 0000000..efdc76a
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline=0:100 -fdisable-ipa-inline" } */
+int g;
+__attribute__((always_inline)) void bar (void)
+{
+  g++;
+}
+
+int foo (void)
+{
+  bar ();
+  return g;
+}
+
+int foo2 (void)
+{
+  bar();
+  return g + 1;
+}
+
+/* { dg-final { scan-tree-dump-times "bar" 5 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+/* { dg-excess-errors "extra notes" } */
diff --git a/gcc/testsuite/gcc.dg/inline_3.c b/gcc/testsuite/gcc.dg/inline_3.c
new file mode 100644 (file)
index 0000000..70a2366
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile   { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline=foo,foo2 -fdisable-ipa-inline" } */
+int g;
+__attribute__((always_inline)) void bar (void)
+{
+  g++;
+}
+
+int foo (void)
+{
+  bar ();
+  return g;
+}
+
+int foo2 (void)
+{
+  bar();
+  return g + 1;
+}
+
+/* { dg-final { scan-tree-dump-times "bar" 5 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+/* { dg-excess-errors "extra notes" } */
diff --git a/gcc/testsuite/gcc.dg/inline_4.c b/gcc/testsuite/gcc.dg/inline_4.c
new file mode 100644 (file)
index 0000000..9a85242
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile  { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline=foo2 -fdisable-ipa-inline" } */
+int g;
+__attribute__((always_inline)) void bar (void)
+{
+  g++;
+}
+
+int foo (void)
+{
+  bar ();
+  return g;
+}
+
+int foo2 (void)
+{
+  bar();
+  return g + 1;
+}
+
+/* { dg-final { scan-tree-dump-times "bar" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+/* { dg-excess-errors "extra notes" } */
diff --git a/gcc/testsuite/gcc.dg/unroll_1.c b/gcc/testsuite/gcc.dg/unroll_1.c
new file mode 100644 (file)
index 0000000..3e8e7a5
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll" } */
+
+unsigned a[100], b[100];
+inline void bar()
+{
+ a[10] = b[10];
+}
+
+int foo(void)
+{
+  int i;
+  bar();
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+int foo2(void)
+{
+  int i;
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+/* { dg-final { scan-rtl-dump-times "Decided to peel loop completely" 2 "loop2_unroll" } } */
+/* { dg-final { cleanup-rtl-dump "loop2_unroll" } } */
+/* { dg-excess-errors "extra notes" } */
diff --git a/gcc/testsuite/gcc.dg/unroll_2.c b/gcc/testsuite/gcc.dg/unroll_2.c
new file mode 100644 (file)
index 0000000..12912cf
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do compile  { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fdisable-tree-cunroll=foo -fdisable-tree-cunrolli=foo -fenable-rtl-loop2_unroll" } */
+
+unsigned a[100], b[100];
+inline void bar()
+{
+ a[10] = b[10];
+}
+
+int foo(void)
+{
+  int i;
+  bar();
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+int foo2(void)
+{
+  int i;
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+/* { dg-final { scan-rtl-dump-times "Decided to peel loop completely" 1 "loop2_unroll" } } */
+/* { dg-final { cleanup-rtl-dump "loop2_unroll" } } */
+/* { dg-excess-errors "extra notes" } */
diff --git a/gcc/testsuite/gcc.dg/unroll_3.c b/gcc/testsuite/gcc.dg/unroll_3.c
new file mode 100644 (file)
index 0000000..d86ed55
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do compile  { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll=foo" } */
+
+unsigned a[100], b[100];
+inline void bar()
+{
+ a[10] = b[10];
+}
+
+int foo(void)
+{
+  int i;
+  bar();
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+int foo2(void)
+{
+  int i;
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+/* { dg-final { scan-rtl-dump-times "Decided to peel loop completely" 1 "loop2_unroll" } } */
+/* { dg-final { cleanup-rtl-dump "loop2_unroll" } } */
+/* { dg-excess-errors "extra notes" } */
diff --git a/gcc/testsuite/gcc.dg/unroll_4.c b/gcc/testsuite/gcc.dg/unroll_4.c
new file mode 100644 (file)
index 0000000..7c70157
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do compile  { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll=foo2" } */
+
+unsigned a[100], b[100];
+inline void bar()
+{
+ a[10] = b[10];
+}
+
+int foo(void)
+{
+  int i;
+  bar();
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+int foo2(void)
+{
+  int i;
+  for (i = 0; i < 2; i++)
+  {
+     a[i]= b[i] + 1;
+  }
+  return 1;
+}
+
+/* { dg-final { scan-rtl-dump-times "Decided to peel loop completely" 1 "loop2_unroll" } } */
+/* { dg-final { cleanup-rtl-dump "loop2_unroll" } } */
+/* { dg-excess-errors "extra notes" } */