diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-03-31 17:21:01 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-03-31 17:21:01 +0000 |
commit | 8d960eda478bc9e710f55aaa0ac8849f6c78465a (patch) | |
tree | 064d1c805c56008fbb6aa9af4651992c8bbd7de6 /gcc/tree-cfg.c | |
parent | 9a9dcce8e8f235bddcbb89bf6010577686b4627b (diff) | |
download | gcc-8d960eda478bc9e710f55aaa0ac8849f6c78465a.zip gcc-8d960eda478bc9e710f55aaa0ac8849f6c78465a.tar.gz gcc-8d960eda478bc9e710f55aaa0ac8849f6c78465a.tar.bz2 |
tree-cfg.c (call_can_make_abnormal_goto): New predicate.
* tree-cfg.c (call_can_make_abnormal_goto): New predicate.
(stmt_can_make_abnormal_goto): Use it.
(is_ctrl_altering_stmt): Likewise.
From-SVN: r186047
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index eb7b62a..1f59c03 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2273,6 +2273,43 @@ gimple_cfg2vcg (FILE *file) Miscellaneous helpers ---------------------------------------------------------------------------*/ +/* Return true if T, a GIMPLE_CALL, can make an abnormal transfer of control + flow. Transfers of control flow associated with EH are excluded. */ + +static bool +call_can_make_abnormal_goto (gimple t) +{ + /* If the function has no non-local labels, then a call cannot make an + abnormal transfer of control. */ + if (!cfun->has_nonlocal_label) + return false; + + /* Likewise if the call has no side effects. */ + if (!gimple_has_side_effects (t)) + return false; + + /* Likewise if the called function is leaf. */ + if (gimple_call_flags (t) & ECF_LEAF) + return false; + + return true; +} + + +/* Return true if T can make an abnormal transfer of control flow. + Transfers of control flow associated with EH are excluded. */ + +bool +stmt_can_make_abnormal_goto (gimple t) +{ + if (computed_goto_p (t)) + return true; + if (is_gimple_call (t)) + return call_can_make_abnormal_goto (t); + return false; +} + + /* Return true if T represents a stmt that always transfers control. */ bool @@ -2306,10 +2343,8 @@ is_ctrl_altering_stmt (gimple t) { int flags = gimple_call_flags (t); - /* A non-pure/const call alters flow control if the current - function has nonlocal labels. */ - if (!(flags & (ECF_CONST | ECF_PURE | ECF_LEAF)) - && cfun->has_nonlocal_label) + /* A call alters control flow if it can make an abnormal goto. */ + if (call_can_make_abnormal_goto (t)) return true; /* A call also alters control flow if it does not return. */ @@ -2367,21 +2402,6 @@ simple_goto_p (gimple t) } -/* Return true if T can make an abnormal transfer of control flow. - Transfers of control flow associated with EH are excluded. */ - -bool -stmt_can_make_abnormal_goto (gimple t) -{ - if (computed_goto_p (t)) - return true; - if (is_gimple_call (t)) - return (gimple_has_side_effects (t) && cfun->has_nonlocal_label - && !(gimple_call_flags (t) & ECF_LEAF)); - return false; -} - - /* Return true if STMT should start a new basic block. PREV_STMT is the statement preceding STMT. It is used when STMT is a label or a case label. Labels should only start a new basic block if their |