From: Richard Biener Date: Thu, 10 Mar 2016 08:06:03 +0000 (+0000) Subject: re PR tree-optimization/70128 (Linux kernel div patching optimized away) X-Git-Tag: basepoints/gcc-7~503 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a81a5941f88c3774e4b337ab275cd6c25508124;p=thirdparty%2Fgcc.git re PR tree-optimization/70128 (Linux kernel div patching optimized away) 2016-03-10 Richard Biener PR tree-optimization/70128 * tree-ssa-structalias.c (set_uids_in_ptset): Set vars_contains_nonlocal for any FUNCTION_DECL or LABEL_DECL. * gcc.dg/tree-ssa/alias-34.c: New testcase. * gcc.dg/tree-ssa/alias-35.c: Likewise. From-SVN: r234099 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a35884fffddb..54f04b046dd2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-03-10 Richard Biener + + PR tree-optimization/70128 + * tree-ssa-structalias.c (set_uids_in_ptset): Set + vars_contains_nonlocal for any FUNCTION_DECL or LABEL_DECL. + 2016-03-09 Jakub Jelinek PR tree-optimization/70152 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eec10fd50013..8ee83bcadbf3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-03-10 Richard Biener + + PR tree-optimization/70128 + * gcc.dg/tree-ssa/alias-34.c: New testcase. + * gcc.dg/tree-ssa/alias-35.c: Likewise. + 2016-03-09 Jakub Jelinek PR tree-optimization/70152 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-34.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-34.c new file mode 100644 index 000000000000..5738feaffb18 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-34.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing -fdump-tree-optimized" } */ + +void foo (int b) +{ + void *p; +lab: + if (b) + p = &&lab; + else + { +lab2: + p = &&lab2; + } + *(char *)p = 1; +} + +/* We should keep the store to the label locations. */ +/* { dg-final { scan-tree-dump " = 1;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-35.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-35.c new file mode 100644 index 000000000000..1ea29885844a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-35.c @@ -0,0 +1,18 @@ +/* PR70128 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing -fdump-tree-optimized" } */ + +void foo (int b) +{ + extern void bar (void); + extern void baz (void); + void *p; + if (b) + p = bar; + else + p = baz; + *(char *)p = 1; +} + +/* We should keep the store to the function locations. */ +/* { dg-final { scan-tree-dump " = 1;" "optimized" } } */ diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index de123800f0b3..bad1ea12a7f9 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -6280,6 +6280,16 @@ set_uids_in_ptset (bitmap into, bitmap from, struct pt_solution *pt, && ! auto_var_in_fn_p (vi->decl, fndecl))) pt->vars_contains_nonlocal = true; } + + else if (TREE_CODE (vi->decl) == FUNCTION_DECL + || TREE_CODE (vi->decl) == LABEL_DECL) + { + /* Nothing should read/write from/to code so we can + save bits by not including them in the points-to bitmaps. + Still mark the points-to set as containing global memory + to make code-patching possible - see PR70128. */ + pt->vars_contains_nonlocal = true; + } } }