diff options
Diffstat (limited to 'gcc/tree-ssa-operands.c')
-rw-r--r-- | gcc/tree-ssa-operands.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index 0f279128f9c..13e20961c13 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -1030,6 +1030,32 @@ get_stmt_operands (tree stmt) } +/* APPLE LOCAL begin lno */ +/* Returns true if the function call EXPR does not access memory. */ + +static bool +function_ignores_memory_p (tree expr) +{ + tree fndecl = get_callee_fndecl (expr); + enum built_in_function fcode; + + if (!fndecl || !DECL_BUILT_IN (fndecl)) + return false; + + fcode = DECL_FUNCTION_CODE (fndecl); + + switch (fcode) + { + case BUILT_IN_PREFETCH: + case BUILT_IN_MAYBE_INFINITE_LOOP: + return true; + + default: + return false; + } +} +/* APPLE LOCAL end lno */ + /* Recursively scan the expression pointed by EXPR_P in statement referred to by INFO. FLAGS is one of the OPF_* constants modifying how to interpret the operands found. */ @@ -1460,12 +1486,26 @@ get_call_expr_operands (tree stmt, tree expr) tree op; int call_flags = call_expr_flags (expr); - if (!bitmap_empty_p (call_clobbered_vars)) + /* If aliases have been computed already, add V_MAY_DEF or V_USE + operands for all the symbols that have been found to be + call-clobbered. + + Note that if aliases have not been computed, the global effects + of calls will not be included in the SSA web. This is fine + because no optimizer should run before aliases have been + computed. By not bothering with virtual operands for CALL_EXPRs + we avoid adding superfluous virtual operands, which can be a + significant compile time sink (See PR 15855). */ + if (aliases_computed_p && !bitmap_empty_p (call_clobbered_vars)) { /* A 'pure' or a 'const' functions never call clobber anything. A 'noreturn' function might, but since we don't return anyway there is no point in recording that. */ - if (TREE_SIDE_EFFECTS (expr) + /* APPLE LOCAL begin lno */ + if (function_ignores_memory_p (expr)) + ; + else if (TREE_SIDE_EFFECTS (expr) + /* APPLE LOCAL end lno */ && !(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN))) add_call_clobber_ops (stmt); else if (!(call_flags & ECF_CONST)) @@ -1496,6 +1536,10 @@ add_stmt_operand (tree *var_p, stmt_ann_t s_ann, int flags) var_ann_t v_ann; var = *var_p; + /* APPLE LOCAL begin lno */ + if (!var) + return; + /* APPLE LOCAL end lno */ STRIP_NOPS (var); /* If the operand is an ADDR_EXPR, add its operand to the list of |