Message ID | 20110106121003.GS16156@tyan-ft48-01.lab.bos.redhat.com |
---|---|
State | New |
Headers | show |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/06/11 05:10, Jakub Jelinek wrote: > Hi! > > If a memcpy/mempcpy/memset has lhs and profile feedback estimates > some likely size, the GIMPLE is invalid, because both calls > use the same SSA_NAME on the lhs. > Fixed thusly, bootstrapped/regtested on i686-linux (x86_64-linux regtest > pending), ok for trunk? > > 2011-01-06 Jakub Jelinek <jakub@redhat.com> > > PR bootstrap/47187 > * value-prof.c (gimple_stringop_fixed_value): Handle > lhs of the call properly. > > * gcc.dg/tree-prof/pr47187.c: New test. OK. Jeff -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJNJ0zCAAoJEBRtltQi2kC7zI4H/RAPBjEr2eV2IPQfxZ+/CXyN 2ji+zwlxolM8O0P6RbXyJAMZSLc4yS9otum1+hMglN7TY0WkCMzkRgQAyeSqf+wa K9iM/TWc471CI2p+QEudBgzwczHNF/vj8pam+bGuq8yArUUcafPF1+GzKdhJmoQv KQK8HdjofouwRruzRJmPy6g/2XrWvavIFlt8B4BoIUYBJ5s9nBW+BHLvDOj6qStK XGOk/KKJMkrZak4Rm3vCYQfPZNbBzRi0NX35vDaCtkEHmv9TyvmwpMCFB3g8ScEi iBzG8pmtkWyKVZSNlRYwGvIS0fmXWsI9rMDh+Z0KlgbdNzjQk+48jg03KvK827Y= =49gv -----END PGP SIGNATURE-----
--- gcc/value-prof.c.jj 2010-12-22 09:54:58.000000000 +0100 +++ gcc/value-prof.c 2011-01-06 11:12:39.000000000 +0100 @@ -1401,6 +1401,21 @@ gimple_stringop_fixed_value (gimple vcal e_vj->probability = REG_BR_PROB_BASE; e_vj->count = all - count; + /* Insert PHI node for the call result if necessary. */ + if (gimple_call_lhs (vcall_stmt) + && TREE_CODE (gimple_call_lhs (vcall_stmt)) == SSA_NAME) + { + tree result = gimple_call_lhs (vcall_stmt); + gimple phi = create_phi_node (result, join_bb); + SSA_NAME_DEF_STMT (result) = phi; + gimple_call_set_lhs (vcall_stmt, + make_ssa_name (SSA_NAME_VAR (result), vcall_stmt)); + add_phi_arg (phi, gimple_call_lhs (vcall_stmt), e_vj, UNKNOWN_LOCATION); + gimple_call_set_lhs (icall_stmt, + make_ssa_name (SSA_NAME_VAR (result), icall_stmt)); + add_phi_arg (phi, gimple_call_lhs (icall_stmt), e_ij, UNKNOWN_LOCATION); + } + /* Because these are all string op builtins, they're all nothrow. */ gcc_assert (!stmt_could_throw_p (vcall_stmt)); gcc_assert (!stmt_could_throw_p (icall_stmt)); --- gcc/testsuite/gcc.dg/tree-prof/pr47187.c.jj 2011-01-06 11:23:10.000000000 +0100 +++ gcc/testsuite/gcc.dg/tree-prof/pr47187.c 2011-01-06 11:20:14.000000000 +0100 @@ -0,0 +1,23 @@ +/* PR bootstrap/47187 */ +/* { dg-options "-O2" } */ + +char buf[64]; +char buf2[64]; + +void * +foo (char *p, long size) +{ + return __builtin_memcpy (buf, p, size); +} + +int +main (void) +{ + long i; + for (i = 0; i < 65536; i++) + if (foo ("abcdefghijkl", 12) != buf) + __builtin_abort (); + if (foo (buf2, 64) != buf) + __builtin_abort (); + return 0; +}