Commit 33579b59 by Jeff Law Committed by Jeff Law

re PR tree-optimization/90037 (-Wnull-dereference false positive after r269302)

	PR tree-optimization/90037
	* Makefile.in (OBJS): Remove tree-ssa-phionlycprop.c
	* passes.def: Replace all instance of phi-only cprop with the
	lattice propagator.  Move propagation pass from after erroneous
	path isolation to before erroneous path isolation.
	* tree-ssa-phionlycprop.c: Remove.

	* gcc.dg/tree-ssa/20030710-1.c: Update dump file to scan.
	* gcc.dg/isolate-2.c: Likewise.
	* gcc.dg/isolate-4.c: Likewise.
	* gcc.dg/pr19431.c: Accept either ordering of PHI args.
	* gcc.dg/pr90037.c: New test.

From-SVN: r270574
parent b16f2147
2019-04-24 Jeff Law <law@redhat.com>
PR tree-optimization/90037
* Makefile.in (OBJS): Remove tree-ssa-phionlycprop.c
* passes.def: Replace all instance of phi-only cprop with the
lattice propagator. Move propagation pass from after erroneous
path isolation to before erroneous path isolation.
* tree-ssa-phionlycprop.c: Remove.
2019-04-24 Richard Biener <rguenther@suse.de> 2019-04-24 Richard Biener <rguenther@suse.de>
PR middle-end/90213 PR middle-end/90213
......
...@@ -1559,7 +1559,6 @@ OBJS = \ ...@@ -1559,7 +1559,6 @@ OBJS = \
tree-ssa-loop.o \ tree-ssa-loop.o \
tree-ssa-math-opts.o \ tree-ssa-math-opts.o \
tree-ssa-operands.o \ tree-ssa-operands.o \
tree-ssa-phionlycprop.o \
tree-ssa-phiopt.o \ tree-ssa-phiopt.o \
tree-ssa-phiprop.o \ tree-ssa-phiprop.o \
tree-ssa-pre.o \ tree-ssa-pre.o \
......
...@@ -222,19 +222,13 @@ along with GCC; see the file COPYING3. If not see ...@@ -222,19 +222,13 @@ along with GCC; see the file COPYING3. If not see
trying to move or duplicate pass_dominator somewhere earlier. */ trying to move or duplicate pass_dominator somewhere earlier. */
NEXT_PASS (pass_thread_jumps); NEXT_PASS (pass_thread_jumps);
NEXT_PASS (pass_dominator, true /* may_peel_loop_headers_p */); NEXT_PASS (pass_dominator, true /* may_peel_loop_headers_p */);
/* At this point the majority of const/copy propagations /* Threading can leave many const/copy propagations in the IL.
are exposed. Go ahead and identify paths that should never Clean them up. Failure to do so well can lead to false
be executed in a conforming program and isolate those paths. positives from warnings for erroneous code. */
NEXT_PASS (pass_copy_prop);
This will expose more degenerate PHIs in the main path and /* Identify paths that should never be executed in a conforming
expose more PRE/DOM optimization opportunities. */ program and isolate those paths. */
NEXT_PASS (pass_isolate_erroneous_paths); NEXT_PASS (pass_isolate_erroneous_paths);
/* The only const/copy propagation opportunities left after
DOM and erroneous path isolation should be due to degenerate PHI nodes.
So rather than run the full propagators, run a specialized pass which
only examines PHIs to discover const/copy propagation
opportunities. */
NEXT_PASS (pass_phi_only_cprop);
NEXT_PASS (pass_dse); NEXT_PASS (pass_dse);
NEXT_PASS (pass_reassoc, true /* insert_powi_p */); NEXT_PASS (pass_reassoc, true /* insert_powi_p */);
NEXT_PASS (pass_dce); NEXT_PASS (pass_dce);
...@@ -321,13 +315,10 @@ along with GCC; see the file COPYING3. If not see ...@@ -321,13 +315,10 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_strlen); NEXT_PASS (pass_strlen);
NEXT_PASS (pass_thread_jumps); NEXT_PASS (pass_thread_jumps);
NEXT_PASS (pass_vrp, false /* warn_array_bounds_p */); NEXT_PASS (pass_vrp, false /* warn_array_bounds_p */);
/* The only const/copy propagation opportunities left after
DOM and VRP should be due to degenerate PHI nodes. So rather than
run the full propagators, run a specialized pass which
only examines PHIs to discover const/copy propagation
opportunities. */
NEXT_PASS (pass_warn_restrict); NEXT_PASS (pass_warn_restrict);
NEXT_PASS (pass_phi_only_cprop); /* Threading can leave many const/copy propagations in the IL.
Clean them up. */
NEXT_PASS (pass_copy_prop);
NEXT_PASS (pass_dse); NEXT_PASS (pass_dse);
NEXT_PASS (pass_cd_dce); NEXT_PASS (pass_cd_dce);
NEXT_PASS (pass_forwprop); NEXT_PASS (pass_forwprop);
......
2019-04-24 Jeff Law <law@redhat.com>
PR tree-optimization/90037
* gcc.dg/tree-ssa/20030710-1.c: Update dump file to scan.
* gcc.dg/isolate-2.c: Likewise.
* gcc.dg/isolate-4.c: Likewise.
* gcc.dg/pr19431.c: Accept either ordering of PHI args.
* gcc.dg/pr90037.c: New test.
2019-04-25 Jakub Jelinek <jakub@redhat.com> 2019-04-25 Jakub Jelinek <jakub@redhat.com>
PR c++/44648 PR c++/44648
......
/* { dg-do compile } */
/* { dg-options "-O2 -Wnull-dereference" } */
typedef __SIZE_TYPE__ size_t;
typedef unsigned long int uintmax_t;
struct group
{
char *gr_name;
char *gr_passwd;
unsigned gr_gid;
char **gr_mem;
};
struct passwd
{
char *pw_name;
char *pw_passwd;
unsigned pw_uid;
unsigned pw_gid;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
};
extern struct group *getgrnam (const char *);
extern struct group *getgrgid (unsigned);
extern void endgrent (void);
extern struct passwd *getpwnam (const char *);
extern void endpwent (void);
extern unsigned long int strtoul (const char *__restrict,
char **__restrict, int);
char const *
parse_with_separator (char const *spec, char const *separator,
unsigned *uid, unsigned *gid,
char **username, char **groupname)
{
static const char *E_invalid_user = "invalid user";
static const char *E_invalid_group = "invalid group";
static const char *E_bad_spec = "invalid spec";
const char *error_msg;
struct passwd *pwd;
struct group *grp;
char *u;
char const *g;
char *gname = 0;
unsigned unum = *uid;
unsigned gnum = gid ? *gid : (unsigned)-1;
error_msg = 0;
if (username)
*username = 0;
if (groupname)
*groupname = 0;
u = 0;
if (separator == 0)
{
if (*spec)
u = __builtin_strdup (spec);
}
else
{
size_t ulen = separator - spec;
if (ulen != 0)
{
u = __builtin_malloc (ulen + 1);
__builtin_memcpy (u, spec, ulen + 1);
u[ulen] = '\0';
}
}
g = (separator == 0 || *(separator + 1) == '\0' ? 0 : separator + 1);
if (u != 0)
{
pwd = (*u == '+' ? 0 : getpwnam (u));
if (pwd == 0)
{
_Bool use_login_group = (separator != 0 && g == 0);
if (use_login_group)
{
error_msg = E_bad_spec;
}
else
{
unsigned long int tmp;
tmp = strtoul (u, 0, 10);
if (tmp <= (1ul << 31) && (unsigned) tmp != (unsigned) -1)
unum = tmp;
else
error_msg = E_invalid_user;
}
}
else
{
unum = pwd->pw_uid;
if (g == 0 && separator != 0)
{
char buf[128];
gnum = pwd->pw_gid;
grp = getgrgid (gnum);
gname = buf;
if (grp)
gname = __builtin_strdup (grp->gr_name);
else
__builtin_snprintf (buf, sizeof(buf), "%ju", (uintmax_t)gnum);
endgrent ();
}
}
endpwent ();
}
if (g != 0 && error_msg == 0)
{
grp = (*g == '+' ? 0 : getgrnam (g));
if (grp == 0)
{
unsigned long int tmp = strtoul (g, 0, 10);
if (tmp <= (1ul << 31) && (unsigned) tmp != (unsigned) -1)
gnum = tmp;
else
error_msg = E_invalid_group;
}
else
gnum = grp->gr_gid;
endgrent ();
gname = __builtin_strdup (g);
}
if (error_msg == 0)
{
*uid = unum;
if (gid)
*gid = gnum;
if (username)
{
*username = u;
u = 0;
}
if (groupname)
{
*groupname = gname;
gname = 0;
}
}
__builtin_free (u);
__builtin_free (gname);
return error_msg ? error_msg : 0;
}
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-phicprop1" } */ /* { dg-options "-O1 -fdump-tree-copyprop2" } */
extern void abort (void); extern void abort (void);
extern void blah (void); extern void blah (void);
...@@ -42,14 +42,14 @@ record_component_aliases (type) ...@@ -42,14 +42,14 @@ record_component_aliases (type)
/* The call to blah should have been eliminated. If the call is not /* The call to blah should have been eliminated. If the call is not
eliminated, then dominator optimizations failed and it'll be eliminated, then dominator optimizations failed and it'll be
impossible to delete other unnecessary code. */ impossible to delete other unnecessary code. */
/* { dg-final { scan-tree-dump-not "blah \\(\\)" "phicprop1" } } */ /* { dg-final { scan-tree-dump-not "blah \\(\\)" "copyprop2" } } */
/* There should be two IF conditionals. */ /* There should be two IF conditionals. */
/* { dg-final { scan-tree-dump-times "if " 2 "phicprop1"} } */ /* { dg-final { scan-tree-dump-times "if " 2 "copyprop2"} } */
/* There should be a single load of type.binfo. */ /* There should be a single load of type.binfo. */
/* { dg-final { scan-tree-dump-times "type\\.binfo" 1 "phicprop1"} } */ /* { dg-final { scan-tree-dump-times "type\\.binfo" 1 "copyprop2"} } */
/* There should be two loads of vec.length. */ /* There should be two loads of vec.length. */
/* { dg-final { scan-tree-dump-times "vec.length" 2 "phicprop1"} } */ /* { dg-final { scan-tree-dump-times "vec.length" 2 "copyprop2"} } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O2 -fdelete-null-pointer-checks -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-phicprop1" } */ /* { dg-options "-O2 -fdelete-null-pointer-checks -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-forwprop3" } */
/* { dg-skip-if "" keeps_null_pointer_checks } */ /* { dg-skip-if "" keeps_null_pointer_checks } */
...@@ -34,9 +34,9 @@ bar (void) ...@@ -34,9 +34,9 @@ bar (void)
a return statement. We test this twice, once where the NULL flows a return statement. We test this twice, once where the NULL flows
from a PHI, the second with an explicit return 0 in the IL. from a PHI, the second with an explicit return 0 in the IL.
We also verify that after isolation phi-cprop simplifies the We also verify that after isolation cprop simplifies the
return statement so that it returns &z directly. */ return statement so that it returns &z directly. */
/* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "isolate-paths"} } */ /* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "isolate-paths"} } */
/* { dg-final { scan-tree-dump-times "return &z;" 1 "phicprop1"} } */ /* { dg-final { scan-tree-dump-times "return &z;" 1 "forwprop3"} } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O2 -fdelete-null-pointer-checks -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-phicprop1" } */ /* { dg-options "-O2 -fdelete-null-pointer-checks -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-ccp3" } */
/* { dg-skip-if "" keeps_null_pointer_checks } */ /* { dg-skip-if "" keeps_null_pointer_checks } */
...@@ -26,6 +26,6 @@ bar (void) ...@@ -26,6 +26,6 @@ bar (void)
We also verify that after isolation phi-cprop simplifies the We also verify that after isolation phi-cprop simplifies the
return statement so that it returns &z directly. */ return statement so that it returns &z directly. */
/* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "isolate-paths"} } */ /* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "isolate-paths"} } */
/* { dg-final { scan-tree-dump-times "foo .&z.;" 1 "phicprop1"} } */ /* { dg-final { scan-tree-dump-times "foo .&z.;" 1 "ccp3"} } */
...@@ -24,4 +24,4 @@ int f(int k, int i1, int j1) ...@@ -24,4 +24,4 @@ int f(int k, int i1, int j1)
return *f1; return *f1;
} }
/* { dg-final { scan-tree-dump "\[^\r\n\]*_. = PHI <i1_\[^,\]*, j1_\[^>\]*>" "optimized" } } */ /* { dg-final { scan-tree-dump "\[^\r\n\]*_. = PHI <\[ij\]1_\[^,\]*, \[ij\]1_\[^>\]*>" "optimized" } } */
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