]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ICF: properly handle LABEL_DECLs (PR tree-opt/81696).
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Aug 2017 11:59:23 +0000 (11:59 +0000)
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Aug 2017 11:59:23 +0000 (11:59 +0000)
2017-08-08  Martin Liska  <mliska@suse.cz>

PR tree-opt/81696
* ipa-icf-gimple.c (func_checker::compare_cst_or_decl): Consider
LABEL_DECLs that can be from a different function.
2017-08-08  Martin Liska  <mliska@suse.cz>

PR tree-opt/81696
* gcc.dg/ipa/pr81696.c: New test.

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

gcc/ChangeLog
gcc/ipa-icf-gimple.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/pr81696.c [new file with mode: 0644]

index d830fd65c12810a7798c420210d559081d5d0299..a5dd5029f87dad3099a4cc7b2c5c57f4e8c54c08 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-08  Martin Liska  <mliska@suse.cz>
+
+       PR tree-opt/81696
+       * ipa-icf-gimple.c (func_checker::compare_cst_or_decl): Consider
+       LABEL_DECLs that can be from a different function.
+
 2017-08-08  Bin Cheng  <bin.cheng@arm.com>
 
        PR tree-optimization/81744
index 08dd980fdf3683c1cc9d4394e0ee048725bda36e..f44a995f580f25ecfc79dbe48a333d4597689223 100644 (file)
@@ -361,10 +361,14 @@ func_checker::compare_cst_or_decl (tree t1, tree t2)
       }
     case LABEL_DECL:
       {
+       if (t1 == t2)
+         return true;
+
        int *bb1 = m_label_bb_map.get (t1);
        int *bb2 = m_label_bb_map.get (t2);
 
-       return return_with_debug (*bb1 == *bb2);
+       /* Labels can point to another function (non-local GOTOs).  */
+       return return_with_debug (bb1 != NULL && bb2 != NULL && *bb1 == *bb2);
       }
     case PARM_DECL:
     case RESULT_DECL:
index 211e629fda311f82591300066805a561c359b3fe..360bb030d668ca791f0acbf68a5087bbe8ca3262 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-08  Martin Liska  <mliska@suse.cz>
+
+       PR tree-opt/81696
+       * gcc.dg/ipa/pr81696.c: New test.
+
 2017-08-08  Bin Cheng  <bin.cheng@arm.com>
 
        PR tree-optimization/81744
diff --git a/gcc/testsuite/gcc.dg/ipa/pr81696.c b/gcc/testsuite/gcc.dg/ipa/pr81696.c
new file mode 100644 (file)
index 0000000..2d3d63f
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-options "-O2 -fdump-ipa-icf-details"  } */
+
+int
+main (int argc, char **argv)
+{
+  __label__ lab4, lab5, lab6;
+
+  void foo (void) { goto lab4; }
+  void foo2 (void) { goto lab4; }
+  void bar (void) { goto lab5; }
+  void baz (void) { goto lab6; }
+
+  if (argc)
+    foo ();
+  else
+    foo2 ();
+
+ lab4:;
+  bar ();
+ lab5:;
+  baz ();
+ lab6:;
+  return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */