diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2003-05-05 21:14:46 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2003-05-05 21:14:46 +0000 |
commit | 68ef8841db44baf4b390349b630dd8bcbdfd5223 (patch) | |
tree | 1f9babb1e5ac2553b24e4cb6ef3e08283d0e9eed /gcc/builtins.c | |
parent | 5f7262e693943229dfd8262e04b122a89b9cdd5f (diff) | |
download | gcc-68ef8841db44baf4b390349b630dd8bcbdfd5223.zip gcc-68ef8841db44baf4b390349b630dd8bcbdfd5223.tar.gz gcc-68ef8841db44baf4b390349b630dd8bcbdfd5223.tar.bz2 |
builtins.c (expand_builtin_stpcpy): Only expand when the length of the source string can be evaluated at compile-time.
* builtins.c (expand_builtin_stpcpy): Only expand when the length
of the source string can be evaluated at compile-time.
From-SVN: r66503
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index dfc17e5..feee531 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -2508,7 +2508,7 @@ expand_builtin_stpcpy (arglist, target, mode) else { tree newarglist; - tree len; + tree src, len; /* If return value is ignored, transform stpcpy into strcpy. */ if (target == const0_rtx) @@ -2527,8 +2527,12 @@ expand_builtin_stpcpy (arglist, target, mode) target, mode, EXPAND_NORMAL); } - len = c_strlen (TREE_VALUE (TREE_CHAIN (arglist))); - if (len == 0) + /* Ensure we get an actual string who length can be evaluated at + compile-time, not an expression containing a string. This is + because the latter will potentially produce pessimized code + when used to produce the return value. */ + src = TREE_VALUE (TREE_CHAIN (arglist)); + if (! c_getstr (src) || ! (len = c_strlen (src))) return 0; len = fold (size_binop (PLUS_EXPR, len, ssize_int (1))); |