From patchwork Fri Nov 24 10:25:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 169379 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1061457vqx; Fri, 24 Nov 2023 02:26:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCcR6cVy12tPyoOG9ombnccRgUKuU/zhCO+YafoDFgm9vVME0QG7x7LXmQzIRJxcYhVyeT X-Received: by 2002:a05:6808:8e8:b0:3ab:38b0:8b84 with SMTP id d8-20020a05680808e800b003ab38b08b84mr2174582oic.17.1700821561575; Fri, 24 Nov 2023 02:26:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700821561; cv=pass; d=google.com; s=arc-20160816; b=jviMCDjq8laxMU9GYI3xFQ/04OmYGPmufmcj5uAhufAxLntuk2yc0R9Spdok8t467B WQL3QkY8UfIHMr+HqOLFvlbnaotRA+glu04JpBkqRTlwZiw8fw43OpUmt9fq22RBL16T Va2Ef/of/dRvox0e1bZiLYxItSbP9fEbo7QMFS94KsDwlWerN74nEK2dd6G25a4JhTXJ A63gx867JTX6RUQcHPwmbz6xphWq7ZqZBydvy2oa81NwyeYC0YupYGoqHjVzEqyXuOob pySHGMY86XLv0UJhtBYWF1rdNKkthWd1aGqMg9K6+llpueYVZC3QeR6HsDbP9c4RlNeZ +ufQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:mime-version:subject :to:from:date:dkim-signature:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=sY+MiXHOfnR5N94AXeZs4hR/4yNltSeJCjh9yGREclo=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=uh9YKtTEVZ2tjcEpEkeZCJylEKwXRRO8ks/Kn2gH6NhF7nSHIN28sZtwfi/1VoW7wU 1KMBsNPelrjuBgAMBiDwryTeJkaNeG1Kwqc366EjTnSR+9P1S3JRtH5q7f4ZTZLJYx9t prubSkxkNuLs2unXoaQN/QV1U4Y0W2qMJoUUlWWfi3fJCE8YXB1AwNtEoBV3VpN8in97 bjSQdWz2jvpJ4VkzunfLArHdX0K6rGaMWZqgf5ss9dRvdFwrMoq6WCYgVEuH9pgK1tOS QAMAIT065lvUHiKM9i4jA0FZ+R1sgrgFpSFxtfDa5gwllzWRDIaqb8tWJZHogJF3rxa0 5LPQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=xwbqR8e1; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ee1-20020a05620a800100b0077d764314fcsi2647854qkb.183.2023.11.24.02.26.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 02:26:01 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=xwbqR8e1; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5711E3858299 for ; Fri, 24 Nov 2023 10:26:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 417813858D39 for ; Fri, 24 Nov 2023 10:25:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 417813858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 417813858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700821539; cv=none; b=Ir+kHsTk+9VCfw5d3PXuXHmYRoJuzaqp2lFqag9BvWnwkgHXCEsCRfSVzc+9Sc3KGf2cRTgR4bqZwnCO0SzmFPvtSye/oPNsX8SjXjfkJe8r7BwhiHsmx+PWRGksKl4VXJl8KThJpxlvM/u36p5LrAaJX9YAIAJ0vYeleQvYmMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700821539; c=relaxed/simple; bh=n36yKBPwp0gN+AF+fbBIxYCYpvX5vKSWNecqk1scSSw=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version: Message-Id; b=VsH4U8bJCeHSMJYnGZglFVyPPvPpSGwqP1cN2hisoTn8IYnzMyFdxBQzMzwfyRPWrEQsvqiGjoOlW2o1/s03bM4rX9lyKBb+Gi5Vv2uHSOqvvmS0J4qe5CKuIAblydiCuuthLDOC75UO/pmJkyLsdJQT3X2Y7peBFX0Ym3IRFA4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 53F2621B69 for ; Fri, 24 Nov 2023 10:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700821537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=sY+MiXHOfnR5N94AXeZs4hR/4yNltSeJCjh9yGREclo=; b=xwbqR8e1syZUAZQUs2mUfGYHAJfBNB2l98N8XNRYHJLAo2O2xtIzONsYpJphDWrxFrZxul nLw+TLvdbn/tlShlo5wQO2V3y3RlFATq9muojXMCUuYJI17BiVtKBYzHcShldQGDzfnU7W zJStDjB18qBUmA2B0ADe/17HKONFx/Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700821537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=sY+MiXHOfnR5N94AXeZs4hR/4yNltSeJCjh9yGREclo=; b=LnLwNQBcGfthj/ACpMYUSvFdHql9s6I67wU6FNDrzAarrodcCDqi7ZBGrut9ECKrxJM9aS 5P/ELQ2aPHBMBXBw== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 34DF8132E2 for ; Fri, 24 Nov 2023 10:25:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 74GICiF6YGVlXgAAn2gu4w (envelope-from ) for ; Fri, 24 Nov 2023 10:25:37 +0000 Date: Fri, 24 Nov 2023 11:25:32 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/112677 - stack corruption with .COND_* reduction MIME-Version: 1.0 Message-Id: <20231124102537.34DF8132E2@imap2.dmz-prg2.suse.org> Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 3.28 X-Spamd-Result: default: False [3.28 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(2.88)[0.961]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_SPAM_LONG(3.50)[1.000]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783440669550861377 X-GMAIL-MSGID: 1783440669550861377 The following makes sure to allocate enough space for vectype_op in vectorizable_reduction. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/112677 * tree-vect-loop.cc (vectorizable_reduction): Use alloca to allocate vectype_op. --- gcc/tree-vect-loop.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index caaed977c89..3df020d2228 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -7385,7 +7385,6 @@ vectorizable_reduction (loop_vec_info loop_vinfo, stmt_vector_for_cost *cost_vec) { tree vectype_in = NULL_TREE; - tree vectype_op[3] = { NULL_TREE, NULL_TREE, NULL_TREE }; class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); enum vect_def_type cond_reduc_dt = vect_unknown_def_type; stmt_vec_info cond_stmt_vinfo = NULL; @@ -7617,6 +7616,7 @@ vectorizable_reduction (loop_vec_info loop_vinfo, assumption is not true: we use reduc_index to record the index of the reduction variable. */ slp_tree *slp_op = XALLOCAVEC (slp_tree, op.num_ops); + tree *vectype_op = XALLOCAVEC (tree, op.num_ops); /* We need to skip an extra operand for COND_EXPRs with embedded comparison. */ unsigned opno_adjust = 0;