From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1251) id 2CF173858C27; Sat, 26 Mar 2022 18:11:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CF173858C27 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Roger Sayle To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7833] PR middle-end/104885: Fix ICE with large stack frame on powerpc64. X-Act-Checkin: gcc X-Git-Author: Roger Sayle X-Git-Refname: refs/heads/master X-Git-Oldrev: 6459e6537632bc06e04e6011ca7fb6488f0e8e7d X-Git-Newrev: 41d1f11f5f693a2a06c65c9467a28dfeb02aed85 Message-Id: <20220326181129.2CF173858C27@sourceware.org> Date: Sat, 26 Mar 2022 18:11:29 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Mar 2022 18:11:29 -0000 https://gcc.gnu.org/g:41d1f11f5f693a2a06c65c9467a28dfeb02aed85 commit r12-7833-g41d1f11f5f693a2a06c65c9467a28dfeb02aed85 Author: Roger Sayle Date: Sat Mar 26 08:10:27 2022 -1000 PR middle-end/104885: Fix ICE with large stack frame on powerpc64. My recent testcase for PR c++/84964.C stress tests the middle-end by attempting to pass a UINT_MAX sized structure on the stack. Although my fix to PR84964 avoids the ICE after sorry on x86_64 and similar targets, a related issue still exists on powerpc64 (and similar ACCUMULATE_OUTGOING_ARGS/ARGS_GROW_DOWNWARD targets) which don't issue a "sorry, unimplemented" message, but instead ICE elsewhere. After attempting several alternate fixes, the simplest solution is to just defensively check in mark_stack_region_used that the upper bound of the region lies within the allocated stack_usage_map array, which is of size highest_outgoing_arg_in_use. When this isn't the case, the code now follows the same path as for variable sized regions, and uses stack_usage_watermark rather than a map. 2022-03-26 Roger Sayle gcc/ChangeLog PR middle-end/104885 * calls.cc (mark_stack_region_used): Check that the region is within the allocated size of stack_usage_map. Diff: --- gcc/calls.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/calls.cc b/gcc/calls.cc index e13469cfd43..4d0bc45be28 100644 --- a/gcc/calls.cc +++ b/gcc/calls.cc @@ -201,7 +201,8 @@ mark_stack_region_used (poly_uint64 lower_bound, poly_uint64 upper_bound) { unsigned HOST_WIDE_INT const_lower, const_upper; const_lower = constant_lower_bound (lower_bound); - if (upper_bound.is_constant (&const_upper)) + if (upper_bound.is_constant (&const_upper) + && const_upper <= highest_outgoing_arg_in_use) for (unsigned HOST_WIDE_INT i = const_lower; i < const_upper; ++i) stack_usage_map[i] = 1; else