Hi, Here is an updated patch version.
Thanks, Ilya -- diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 52d9ab0..9d7ae85 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3030,40 +3030,54 @@ gimple_check_call_args (gimple stmt, tree fndecl, bool args_count_match) { for (i = 0, p = DECL_ARGUMENTS (fndecl); i < nargs; - i++, p = DECL_CHAIN (p)) + i++) { - tree arg; + tree arg = gimple_call_arg (stmt, i); + + /* Skip bound args inserted by Pointer Bounds Checker. */ + if (POINTER_BOUNDS_P (arg)) + continue; + /* We cannot distinguish a varargs function from the case of excess parameters, still deferring the inlining decision to the callee is possible. */ if (!p) break; - arg = gimple_call_arg (stmt, i); + if (p == error_mark_node || arg == error_mark_node || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg)) && !fold_convertible_p (DECL_ARG_TYPE (p), arg))) return false; + + p = DECL_CHAIN (p); } if (args_count_match && p) return false; } else if (parms) { - for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) + for (i = 0, p = parms; i < nargs; i++) { - tree arg; + tree arg = gimple_call_arg (stmt, i); + + /* Skip bound args inserted by Pointer Bounds Checker. */ + if (POINTER_BOUNDS_P (arg)) + continue; + /* If this is a varargs function defer inlining decision to callee. */ if (!p) break; - arg = gimple_call_arg (stmt, i); + if (TREE_VALUE (p) == error_mark_node || arg == error_mark_node || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg)) && !fold_convertible_p (TREE_VALUE (p), arg))) return false; + + p = TREE_CHAIN (p); } } else diff --git a/gcc/gimple.c b/gcc/gimple.c index 20f6010..0fc704b 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -3043,20 +3043,27 @@ canonicalize_cond_expr_cond (tree t) } /* Build a GIMPLE_CALL identical to STMT but skipping the arguments in - the positions marked by the set ARGS_TO_SKIP. */ + the positions marked by the set ARGS_TO_SKIP. ARGS_TO_SKIP does not + take into account bounds arguments. Bounds passed for skipped args + are also skipped. */ gimple gimple_call_copy_skip_args (gimple stmt, bitmap args_to_skip) { - int i; + int i, bit; int nargs = gimple_call_num_args (stmt); vec<tree> vargs; vargs.create (nargs); gimple new_stmt; - for (i = 0; i < nargs; i++) - if (!bitmap_bit_p (args_to_skip, i)) - vargs.quick_push (gimple_call_arg (stmt, i)); + for (i = 0, bit = 0; i < nargs; i++, bit++) + if (POINTER_BOUNDS_P (gimple_call_arg (stmt, i))) + { + if (!bitmap_bit_p (args_to_skip, --bit)) + vargs.quick_push (gimple_call_arg (stmt, i)); + } + else if (!bitmap_bit_p (args_to_skip, bit)) + vargs.quick_push (gimple_call_arg (stmt, i)); if (gimple_call_internal_p (stmt)) new_stmt = gimple_build_call_internal_vec (gimple_call_internal_fn (stmt), @@ -3702,6 +3709,9 @@ validate_call (gimple stmt, tree fndecl) if (!targs) return true; tree arg = gimple_call_arg (stmt, i); + /* Skip bounds. */ + if (POINTER_BOUNDS_P (arg)) + continue; if (INTEGRAL_TYPE_P (TREE_TYPE (arg)) && INTEGRAL_TYPE_P (TREE_VALUE (targs))) ;