diff options
author | Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> | 2017-04-29 10:05:13 +0000 |
---|---|---|
committer | Prathamesh Kulkarni <prathamesh3492@gcc.gnu.org> | 2017-04-29 10:05:13 +0000 |
commit | fe75f73248425f0f4c0d2196811ce1d7afb9c09f (patch) | |
tree | 9e0c2d1d28b1e5baecc44a4c7b78ad81f0e1bef3 /gcc/tree-ssa-dce.c | |
parent | 6bcd876838b433fd2730a6a15740ddcecbefd9ea (diff) |
re PR tree-optimization/79697 (unused realloc(0, n) not eliminated)
2017-04-29 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/79697
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Check if callee
is BUILT_IN_STRDUP, BUILT_IN_STRNDUP, BUILT_IN_REALLOC.
(propagate_necessity): Check if def_callee is BUILT_IN_STRDUP or
BUILT_IN_STRNDUP.
* gimple-fold.c (gimple_fold_builtin_realloc): New function.
(gimple_fold_builtin): Call gimple_fold_builtin_realloc.
testsuite/
* gcc.dg/tree-ssa/pr79697.c: New test.
From-SVN: r247407
Diffstat (limited to 'gcc/tree-ssa-dce.c')
-rw-r--r-- | gcc/tree-ssa-dce.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 5ebe57b0983..e17659df91f 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -233,6 +233,8 @@ mark_stmt_if_obviously_necessary (gimple *stmt, bool aggressive) case BUILT_IN_CALLOC: case BUILT_IN_ALLOCA: case BUILT_IN_ALLOCA_WITH_ALIGN: + case BUILT_IN_STRDUP: + case BUILT_IN_STRNDUP: return; default:; @@ -780,7 +782,9 @@ propagate_necessity (bool aggressive) && DECL_BUILT_IN_CLASS (def_callee) == BUILT_IN_NORMAL && (DECL_FUNCTION_CODE (def_callee) == BUILT_IN_ALIGNED_ALLOC || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_MALLOC - || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_CALLOC)) + || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_CALLOC + || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_STRDUP + || DECL_FUNCTION_CODE (def_callee) == BUILT_IN_STRNDUP)) { gimple *bounds_def_stmt; tree bounds; |