tree-ssa-strlen.c (printf_strlen_execute): Initialize the loop optimizer and SCEV before sizing ssa_ver_to_stridx.

* tree-ssa-strlen.c (printf_strlen_execute): Initialize
	the loop optimizer and SCEV before sizing ssa_ver_to_stridx.

	* gcc.c-torture/compile/20190827-1.c: New test.

From-SVN: r274975
This commit is contained in:
Jeff Law 2019-08-27 17:03:45 -06:00 committed by Jeff Law
parent 2bd86b95f7
commit 2d8ba44101
4 changed files with 122 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2019-08-27 Jeff Law <law@redhat.com>
* tree-ssa-strlen.c (printf_strlen_execute): Initialize
the loop optimizer and SCEV before sizing ssa_ver_to_stridx.
2019-08-27 Uroš Bizjak <ubizjak@gmail.com>
PR target/91528

View File

@ -1,3 +1,7 @@
2019-08-27 Jeff Law <law@redhat.com>
* gcc.c-torture/compile/20190827-1.c: New test.
2019-08-27 Harald Anlauf <anlauf@gmx.de>
PR fortran/91496

View File

@ -0,0 +1,104 @@
typedef unsigned char __u8;
typedef __u8 u8;
typedef u8 u_int8_t;
typedef unsigned int gfp_t;
struct list_head
{
struct list_head *next, *prev;
};
extern int strcmp (const char *, const char *);
enum
{
NFPROTO_UNSPEC = 0,
NFPROTO_INET = 1,
NFPROTO_IPV4 = 2,
NFPROTO_ARP = 3,
NFPROTO_NETDEV = 5,
NFPROTO_BRIDGE = 7,
NFPROTO_IPV6 = 10,
NFPROTO_DECNET = 12,
NFPROTO_NUMPROTO,
};
struct xt_target
{
struct list_head list;
const char name[29];
u_int8_t revision;
};
struct xt_af
{
struct list_head target;
};
static struct xt_af *xt;
struct xt_af * kcalloc (int, int, int);
static int
target_revfn (u8 af, const char *name, u8 revision, int *bestp)
{
const struct xt_target *t;
int have_rev = 0;
for (t = (
{
void *__mptr = (void *)((&xt[af].target)->next);
((typeof (*t) *) (__mptr -
__builtin_offsetof (typeof (*t), list)));}
); &t->list != (&xt[af].target); t = (
{
void *__mptr =
(void *)((t)->list.next);
((typeof (*(t)) *) (__mptr -
__builtin_offsetof
(typeof
(*(t)),
list)));}
))
{
if (strcmp (t->name, name) == 0)
{
if (t->revision > *bestp)
*bestp = t->revision;
if (t->revision == revision)
have_rev = 1;
}
}
if (af != NFPROTO_UNSPEC && !have_rev)
return target_revfn (NFPROTO_UNSPEC, name, revision, bestp);
return have_rev;
}
int
xt_find_revision (u8 af, const char *name, u8 revision, int target, int *err)
{
int have_rev, best = -1;
have_rev = target_revfn (af, name, revision, &best);
if (best == -1)
{
*err = -2;
return 0;
}
}
static int __attribute__ ((__section__ (".init.text")))
__attribute__ ((__cold__)) xt_init (void)
{
xt =
kcalloc (NFPROTO_NUMPROTO, sizeof (struct xt_af),
(((gfp_t) (0x400u | 0x800u)) | ((gfp_t) 0x40u) |
((gfp_t) 0x80u)));
}
int init_module (void) __attribute__ ((__copy__ (xt_init)))
__attribute__ ((alias ("xt_init")));;

View File

@ -4850,13 +4850,6 @@ printf_strlen_execute (function *fun, bool warn_only)
{
strlen_optimize = !warn_only;
gcc_assert (!strlen_to_stridx);
if (warn_stringop_overflow || warn_stringop_truncation)
strlen_to_stridx = new hash_map<tree, stridx_strlenloc> ();
ssa_ver_to_stridx.safe_grow_cleared (num_ssa_names);
max_stridx = 1;
calculate_dominance_info (CDI_DOMINATORS);
bool use_scev = optimize > 0 && flag_printf_return_value;
@ -4866,6 +4859,15 @@ printf_strlen_execute (function *fun, bool warn_only)
scev_initialize ();
}
gcc_assert (!strlen_to_stridx);
if (warn_stringop_overflow || warn_stringop_truncation)
strlen_to_stridx = new hash_map<tree, stridx_strlenloc> ();
/* This has to happen after initializing the loop optimizer
and initializing SCEV as they create new SSA_NAMEs. */
ssa_ver_to_stridx.safe_grow_cleared (num_ssa_names);
max_stridx = 1;
/* String length optimization is implemented as a walk of the dominator
tree and a forward walk of statements within each block. */
strlen_dom_walker walker (CDI_DOMINATORS);