diff options
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 eb7b62a72c5..1f59c03cfcd 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 |