The following patch removes the only user of gimple_fold_builtin, using the "proper" fold_stmt API.
Boostrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2014-08-01 Richard Biener <rguent...@suse.de> * gimple-fold.h (gimple_fold_builtin): Remove. * gimple-fold.c (gimple_fold_builtin): Make static. * tree-ssa-ccp.c (pass_fold_builtins::execute): Use fold_stmt, not gimple_fold_builtin. Index: gcc/gimple-fold.h =================================================================== *** gcc/gimple-fold.h.orig 2014-08-04 12:52:53.994431783 +0200 --- gcc/gimple-fold.h 2014-08-04 12:53:04.948431029 +0200 *************** along with GCC; see the file COPYING3. *** 25,31 **** extern tree canonicalize_constructor_val (tree, tree); extern tree get_symbol_constant_value (tree); extern void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree); - extern tree gimple_fold_builtin (gimple); extern bool fold_stmt (gimple_stmt_iterator *); extern bool fold_stmt_inplace (gimple_stmt_iterator *); extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree, --- 25,30 ---- Index: gcc/tree-ssa-ccp.c =================================================================== *** gcc/tree-ssa-ccp.c.orig 2014-08-04 12:52:53.994431783 +0200 --- gcc/tree-ssa-ccp.c 2014-08-04 13:16:28.512334396 +0200 *************** pass_fold_builtins::execute (function *f *** 2676,2682 **** for (i = gsi_start_bb (bb); !gsi_end_p (i); ) { gimple stmt, old_stmt; ! tree callee, result; enum built_in_function fcode; stmt = gsi_stmt (i); --- 2676,2682 ---- for (i = gsi_start_bb (bb); !gsi_end_p (i); ) { gimple stmt, old_stmt; ! tree callee; enum built_in_function fcode; stmt = gsi_stmt (i); *************** pass_fold_builtins::execute (function *f *** 2701,2762 **** gsi_next (&i); continue; } callee = gimple_call_fndecl (stmt); if (!callee || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL) { gsi_next (&i); continue; } - fcode = DECL_FUNCTION_CODE (callee); - - result = gimple_fold_builtin (stmt); ! if (result) ! gimple_remove_stmt_histograms (fun, stmt); ! if (!result) ! switch (DECL_FUNCTION_CODE (callee)) ! { ! case BUILT_IN_CONSTANT_P: ! /* Resolve __builtin_constant_p. If it hasn't been ! folded to integer_one_node by now, it's fairly ! certain that the value simply isn't constant. */ ! result = integer_zero_node; ! break; ! ! case BUILT_IN_ASSUME_ALIGNED: ! /* Remove __builtin_assume_aligned. */ ! result = gimple_call_arg (stmt, 0); ! break; ! ! case BUILT_IN_STACK_RESTORE: ! result = optimize_stack_restore (i); ! if (result) break; - gsi_next (&i); - continue; ! case BUILT_IN_UNREACHABLE: ! if (optimize_unreachable (i)) ! cfg_changed = true; ! break; ! ! case BUILT_IN_VA_START: ! case BUILT_IN_VA_END: ! case BUILT_IN_VA_COPY: ! /* These shouldn't be folded before pass_stdarg. */ ! result = optimize_stdarg_builtin (stmt); ! if (result) break; - /* FALLTHRU */ ! default: ! gsi_next (&i); ! continue; ! } ! if (result == NULL_TREE) ! break; if (dump_file && (dump_flags & TDF_DETAILS)) { --- 2701,2769 ---- gsi_next (&i); continue; } + callee = gimple_call_fndecl (stmt); if (!callee || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL) { gsi_next (&i); continue; } ! fcode = DECL_FUNCTION_CODE (callee); ! if (fold_stmt (&i)) ! ; ! else ! { ! tree result = NULL_TREE; ! switch (DECL_FUNCTION_CODE (callee)) ! { ! case BUILT_IN_CONSTANT_P: ! /* Resolve __builtin_constant_p. If it hasn't been ! folded to integer_one_node by now, it's fairly ! certain that the value simply isn't constant. */ ! result = integer_zero_node; ! break; ! case BUILT_IN_ASSUME_ALIGNED: ! /* Remove __builtin_assume_aligned. */ ! result = gimple_call_arg (stmt, 0); break; ! case BUILT_IN_STACK_RESTORE: ! result = optimize_stack_restore (i); ! if (result) ! break; ! gsi_next (&i); ! continue; ! ! case BUILT_IN_UNREACHABLE: ! if (optimize_unreachable (i)) ! cfg_changed = true; break; ! case BUILT_IN_VA_START: ! case BUILT_IN_VA_END: ! case BUILT_IN_VA_COPY: ! /* These shouldn't be folded before pass_stdarg. */ ! result = optimize_stdarg_builtin (stmt); ! if (result) ! break; ! /* FALLTHRU */ ! default:; ! } ! ! if (!result) ! { ! gsi_next (&i); ! continue; ! } ! ! if (!update_call_from_tree (&i, result)) ! gimplify_and_update_call_from_tree (&i, result); ! } ! ! todoflags |= TODO_update_address_taken; if (dump_file && (dump_flags & TDF_DETAILS)) { *************** pass_fold_builtins::execute (function *f *** 2765,2776 **** } old_stmt = stmt; - if (!update_call_from_tree (&i, result)) - { - gimplify_and_update_call_from_tree (&i, result); - todoflags |= TODO_update_address_taken; - } - stmt = gsi_stmt (i); update_stmt (stmt); --- 2772,2777 ---- Index: gcc/gimple-fold.c =================================================================== *** gcc/gimple-fold.c.orig 2014-08-04 12:52:53.994431783 +0200 --- gcc/gimple-fold.c 2014-08-04 12:53:04.960431028 +0200 *************** get_maxval_strlen (tree arg, tree *lengt *** 873,879 **** Note that some builtins expand into inline code that may not be valid in GIMPLE. Callers must take care. */ ! tree gimple_fold_builtin (gimple stmt) { tree result, val[3]; --- 873,879 ---- Note that some builtins expand into inline code that may not be valid in GIMPLE. Callers must take care. */ ! static tree gimple_fold_builtin (gimple stmt) { tree result, val[3];