diff options
author | Marek Polacek <polacek@redhat.com> | 2016-05-24 13:34:37 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-05-24 13:34:37 +0000 |
commit | abd3a68c1343af515a1f9b5e60f2b6ed94ee1d7a (patch) | |
tree | 5012ef61f6549f21b9eb5ed7fd9978b9a7d872f0 /gcc | |
parent | 30fd2977745d53f282d1560212e3bea07943a937 (diff) | |
download | gcc-abd3a68c1343af515a1f9b5e60f2b6ed94ee1d7a.zip gcc-abd3a68c1343af515a1f9b5e60f2b6ed94ee1d7a.tar.gz gcc-abd3a68c1343af515a1f9b5e60f2b6ed94ee1d7a.tar.bz2 |
tree-cfg.h (should_remove_lhs_p): New predicate.
* tree-cfg.h (should_remove_lhs_p): New predicate.
* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Use it.
* gimplify.c (gimplify_modify_expr): Likewise.
* tree-cfg.c (verify_gimple_call): Likewise.
* tree-cfgcleanup.c (fixup_noreturn_call): Likewise.
* gimple-fold.c: Include "tree-cfg.h".
(gimple_fold_call): Use should_remove_lhs_p.
From-SVN: r236637
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cgraph.c | 5 | ||||
-rw-r--r-- | gcc/gimple-fold.c | 8 | ||||
-rw-r--r-- | gcc/gimplify.c | 4 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 6 | ||||
-rw-r--r-- | gcc/tree-cfg.h | 10 | ||||
-rw-r--r-- | gcc/tree-cfgcleanup.c | 3 |
7 files changed, 28 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cd557fb..8a1e9da 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2016-05-24 Marek Polacek <polacek@redhat.com> + + * tree-cfg.h (should_remove_lhs_p): New predicate. + * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Use it. + * gimplify.c (gimplify_modify_expr): Likewise. + * tree-cfg.c (verify_gimple_call): Likewise. + * tree-cfgcleanup.c (fixup_noreturn_call): Likewise. + * gimple-fold.c: Include "tree-cfg.h". + (gimple_fold_call): Use should_remove_lhs_p. + 2016-05-24 Richard Biener <rguenther@suse.de> PR tree-optimization/71253 diff --git a/gcc/cgraph.c b/gcc/cgraph.c index cf9192f..1a4f665 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1513,10 +1513,7 @@ cgraph_edge::redirect_call_stmt_to_callee (void) } /* If the call becomes noreturn, remove the LHS if possible. */ - if (lhs - && (gimple_call_flags (new_stmt) & ECF_NORETURN) - && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST - && !TREE_ADDRESSABLE (TREE_TYPE (lhs))) + if (gimple_call_noreturn_p (new_stmt) && should_remove_lhs_p (lhs)) { if (TREE_CODE (lhs) == SSA_NAME) { diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 83b7150..d6657e9 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see #include "optabs-query.h" #include "omp-low.h" #include "ipa-chkp.h" +#include "tree-cfg.h" /* Return true when DECL can be referenced from current unit. @@ -3052,12 +3053,9 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) == void_type_node)) gimple_call_set_fntype (stmt, TREE_TYPE (fndecl)); /* If the call becomes noreturn, remove the lhs. */ - if (lhs - && (gimple_call_flags (stmt) & ECF_NORETURN) + if (gimple_call_noreturn_p (stmt) && (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (stmt))) - || ((TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) - == INTEGER_CST) - && !TREE_ADDRESSABLE (TREE_TYPE (lhs))))) + || should_remove_lhs_p (lhs))) { if (TREE_CODE (lhs) == SSA_NAME) { diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 6473544..e702bc4 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4873,9 +4873,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, } } notice_special_calls (call_stmt); - if (!gimple_call_noreturn_p (call_stmt) - || TREE_ADDRESSABLE (TREE_TYPE (*to_p)) - || TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (*to_p))) != INTEGER_CST) + if (!gimple_call_noreturn_p (call_stmt) || !should_remove_lhs_p (*to_p)) gimple_call_set_lhs (call_stmt, *to_p); else if (TREE_CODE (*to_p) == SSA_NAME) /* The above is somewhat premature, avoid ICEing later for a diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 7c2ee78..82f0da6c 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3385,11 +3385,9 @@ verify_gimple_call (gcall *stmt) return true; } - if (lhs - && gimple_call_ctrl_altering_p (stmt) + if (gimple_call_ctrl_altering_p (stmt) && gimple_call_noreturn_p (stmt) - && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST - && !TREE_ADDRESSABLE (TREE_TYPE (lhs))) + && should_remove_lhs_p (lhs)) { error ("LHS in noreturn call"); return true; diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h index 802e292..3e2a1ee 100644 --- a/gcc/tree-cfg.h +++ b/gcc/tree-cfg.h @@ -108,4 +108,14 @@ extern bool gimple_find_sub_bbs (gimple_seq, gimple_stmt_iterator *); extern bool extract_true_false_controlled_edges (basic_block, basic_block, edge *, edge *); +/* Return true if the LHS of a call should be removed. */ + +inline bool +should_remove_lhs_p (tree lhs) +{ + return (lhs + && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST + && !TREE_ADDRESSABLE (TREE_TYPE (lhs))); +} + #endif /* _TREE_CFG_H */ diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 46d0fa3..4134c38 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -604,8 +604,7 @@ fixup_noreturn_call (gimple *stmt) temporaries of variable-sized types is not supported. Also don't do this with TREE_ADDRESSABLE types, as assign_temp will abort. */ tree lhs = gimple_call_lhs (stmt); - if (lhs && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST - && !TREE_ADDRESSABLE (TREE_TYPE (lhs))) + if (should_remove_lhs_p (lhs)) { gimple_call_set_lhs (stmt, NULL_TREE); |