/* Control flow functions for trees.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
- 2010, 2011 Free Software Foundation, Inc.
+ 2010, 2011, 2012 Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC.
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
{
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. */
}
-/* 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
{
CASE_CONVERT:
{
- /* Allow conversions between integral types and pointers only if
+ /* Allow conversions from pointer type to integral type only if
there is no sign or zero extension involved.
For targets were the precision of ptrofftype doesn't match that
- of pointers we need to allow arbitrary conversions from and
- to ptrofftype. */
+ of pointers we need to allow arbitrary conversions to ptrofftype. */
if ((POINTER_TYPE_P (lhs_type)
- && INTEGRAL_TYPE_P (rhs1_type)
- && (TYPE_PRECISION (lhs_type) >= TYPE_PRECISION (rhs1_type)
- || ptrofftype_p (rhs1_type)))
+ && INTEGRAL_TYPE_P (rhs1_type))
|| (POINTER_TYPE_P (rhs1_type)
&& INTEGRAL_TYPE_P (lhs_type)
&& (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FORK))
return false;
- if (is_gimple_call (t)
- && !(call_flags & ECF_NORETURN))
- return true;
+ if (is_gimple_call (t))
+ {
+ edge_iterator ei;
+ edge e;
+ basic_block bb;
+
+ if (!(call_flags & ECF_NORETURN))
+ return true;
+
+ bb = gimple_bb (t);
+ FOR_EACH_EDGE (e, ei, bb->succs)
+ if ((e->flags & EDGE_FAKE) == 0)
+ return true;
+ }
if (gimple_code (t) == GIMPLE_ASM
&& (gimple_asm_volatile_p (t) || gimple_asm_input_p (t)))
/* Add fake edges to the function exit for any non constant and non
- noreturn calls, volatile inline assembly in the bitmap of blocks
- specified by BLOCKS or to the whole CFG if BLOCKS is zero. Return
- the number of blocks that were split.
+ noreturn calls (or noreturn calls with EH/abnormal edges),
+ volatile inline assembly in the bitmap of blocks specified by BLOCKS
+ or to the whole CFG if BLOCKS is zero. Return the number of blocks
+ that were split.
The goal is to expose cases in which entering a basic block does
not imply that all subsequent instructions must be executed. */