PR 95581 reports an ICE in a call to gimple_call_arg() with an out-of-bounds argument number (2). The attached patch avoids the ICE but I'm not sure it's the right fix. Other than verifying the ICE is gone with a powerpc64 cross-compiler I couldn't come up with a generic test cases to exercise this change.
The call, synthesized by the vectorizer, is vect__5.6_24 = __builtin_altivec_mask_for_load (vectp_a.5_8); but the function is declared by the powerpc64 back end to take two arguments: long and const void*. Is it correct for the builtin to be called with fewer arguments than their type indicates? (If it isn't the patch shouldn't be necessary but some other fix would be needed.) Martin
PR tree-optimization/95581 - ICE in gimple_call_arg for a call with fewer arguments than function type implies gcc/ChangeLog: PR tree-optimization/95581 * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Guard against calls with fewer arguments than the called function type implies. diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 2f0ff724cde..52f2de940c0 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -445,7 +445,7 @@ maybe_warn_pass_by_reference (gimple *stmt, wlimits &wlims) if (!wlims.wmaybe_uninit) return; - unsigned nargs = gimple_call_num_args (stmt); + const unsigned nargs = gimple_call_num_args (stmt); if (!nargs) return; @@ -480,6 +480,11 @@ maybe_warn_pass_by_reference (gimple *stmt, wlimits &wlims) FOREACH_FUNCTION_ARGS (fntype, argtype, it) { + /* Guard against calls with fewer arguments than the function + type implies. See PR 95581. */ + if (nargs == argno) + break; + ++argno; if (!POINTER_TYPE_P (argtype))