Commit d81e058f by Martin Liska Committed by Martin Liska

ICF: properly handle LABEL_DECLs (PR tree-opt/81696).

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.

From-SVN: r250951
parent a5c93f53
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> 2017-08-08 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/81744 PR tree-optimization/81744
......
...@@ -361,10 +361,14 @@ func_checker::compare_cst_or_decl (tree t1, tree t2) ...@@ -361,10 +361,14 @@ func_checker::compare_cst_or_decl (tree t1, tree t2)
} }
case LABEL_DECL: case LABEL_DECL:
{ {
if (t1 == t2)
return true;
int *bb1 = m_label_bb_map.get (t1); int *bb1 = m_label_bb_map.get (t1);
int *bb2 = m_label_bb_map.get (t2); 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 PARM_DECL:
case RESULT_DECL: case RESULT_DECL:
......
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> 2017-08-08 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/81744 PR tree-optimization/81744
......
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment