diff options
author | Richard Biener <rguenther@suse.de> | 2014-08-27 08:01:25 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-08-27 08:01:25 +0000 |
commit | 07f1cf564b3b64096998da79ea1963e100688a0e (patch) | |
tree | 60748f8fb1fb8fb65da82dd94574e47a560dbb66 /gcc/gimple-fold.c | |
parent | 53fa2d27a0275e03696351dc2a178ed12fb9b6ed (diff) | |
download | gcc-07f1cf564b3b64096998da79ea1963e100688a0e.zip gcc-07f1cf564b3b64096998da79ea1963e100688a0e.tar.gz gcc-07f1cf564b3b64096998da79ea1963e100688a0e.tar.bz2 |
re PR lto/62239 (ICE: in execute_todo, at passes.c:1795 with LTO)
2014-08-27 Richard Biener <rguenther@suse.de>
PR middle-end/62239
* builtins.c (fold_builtin_strcat_chk): Move to gimple-fold.c.
(fold_builtin_3): Do not fold strcat_chk here.
* gimple-fold.c (gimple_fold_builtin_strcat_chk): Move here
from builtins.c.
(gimple_fold_builtin): Fold strcat_chk here.
From-SVN: r214564
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index f4fe65b..7538ec0 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1587,6 +1587,41 @@ gimple_fold_builtin_strcat (gimple_stmt_iterator *gsi, return true; } +/* Fold a call to the __strcat_chk builtin FNDECL. DEST, SRC, and SIZE + are the arguments to the call. */ + +static bool +gimple_fold_builtin_strcat_chk (gimple_stmt_iterator *gsi) +{ + gimple stmt = gsi_stmt (*gsi); + tree dest = gimple_call_arg (stmt, 0); + tree src = gimple_call_arg (stmt, 1); + tree size = gimple_call_arg (stmt, 2); + tree fn; + const char *p; + + + p = c_getstr (src); + /* If the SRC parameter is "", return DEST. */ + if (p && *p == '\0') + { + replace_call_with_value (gsi, dest); + return true; + } + + if (! tree_fits_uhwi_p (size) || ! integer_all_onesp (size)) + return false; + + /* If __builtin_strcat_chk is used, assume strcat is available. */ + fn = builtin_decl_explicit (BUILT_IN_STRCAT); + if (!fn) + return false; + + gimple repl = gimple_build_call (fn, 2, dest, src); + replace_call_with_call_and_fold (gsi, repl); + return true; +} + /* Fold a call to the fputs builtin. ARG0 and ARG1 are the arguments to the call. IGNORE is true if the value returned by the builtin will be ignored. UNLOCKED is true is true if this @@ -2569,6 +2604,8 @@ gimple_fold_builtin (gimple_stmt_iterator *gsi) case BUILT_IN_SPRINTF_CHK: case BUILT_IN_VSPRINTF_CHK: return gimple_fold_builtin_sprintf_chk (gsi, DECL_FUNCTION_CODE (callee)); + case BUILT_IN_STRCAT_CHK: + return gimple_fold_builtin_strcat_chk (gsi); default:; } |