From patchwork Thu Feb 17 09:18:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1594073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Nu+cNw3S; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jzq5M3Jpcz9sFk for ; Thu, 17 Feb 2022 20:19:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 21F04385780E for ; Thu, 17 Feb 2022 09:18:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21F04385780E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1645089539; bh=4tlGqmtZblO8bFk9t0bfZ6ffwGcSTSHKPz3WkJMdmB4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Nu+cNw3SOt175uNhDm5KBku3qp9T/bOY43BWhj6vC66U4zDmwVzbfPvQAVZNaDiow 9ExhJwrkHnNbZOB6ktVnjafrV1bQ/OrLgVOJBo5X6ypaXjdsXLlNDGeKI43H9CuB9+ goZvxP+sWpkwrs7YItoYA+zPb1ntHivGoW9NHQMQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 3215D3858D20 for ; Thu, 17 Feb 2022 09:18:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3215D3858D20 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-HB0EU7EpNcCxAgnHDkvQvg-1; Thu, 17 Feb 2022 04:18:35 -0500 X-MC-Unique: HB0EU7EpNcCxAgnHDkvQvg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 781CA1091DA2; Thu, 17 Feb 2022 09:18:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D10F15F902; Thu, 17 Feb 2022 09:18:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 21H9IQJi1671595 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 17 Feb 2022 10:18:27 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 21H9IQ8r1671592; Thu, 17 Feb 2022 10:18:26 +0100 Date: Thu, 17 Feb 2022 10:18:25 +0100 To: Richard Biener , Jeff Law Subject: [PATCH] calls: When bypassing emit_push_insn for 0 sized arg, emit at least anti_adjust_stack for alignment pad if needed [PR104558] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: Marek Polacek , gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! The following testcase ICEs on x86_64 when asked to use the pre-GCC 8 ABI where zero sized arguments weren't ignored. In GCC 7 the emit_push_insn calls in store_one_arg were unconditional, it is true that they didn't actually push anything because it had zero size, but because arg->locate.alignment_pad is 8 in this case, emit_push_insn at the end performs if (alignment_pad && args_addr == 0) anti_adjust_stack (alignment_pad); and an assert larger on is upset if we don't do it. The following patch keeps the emit_push_insn conditional but calls the anti_adjust_stack when needed by hand for the zero sized arguments. For the new x86_64 ABI where zero sized arguments are ignored arg->locate.alignment_pad is 0 in this case, so nothing changes - we in that case really do ignore it. There is another emit_push_insn call earlier in store_one_arg, also made conditional on non-zero size by Marek in GCC 8, but that one is for arguments with non-BLKmode and the only way those can be zero size is if they are TYPE_EMPTY_P aka when they are completely ignored. But I believe arg->locate.alignment_pad should be 0 in that case, so IMHO there is no need to do anything in the second spot. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-02-17 Jakub Jelinek PR middle-end/104558 * calls.cc (store_one_arg): When not calling emit_push_insn because size_rtx is const0_rtx, call at least anti_adjust_stack on arg->locate.alignment_pad if !argblock and the alignment might be non-zero. * gcc.dg/pr104558.c: New test. Jakub --- gcc/calls.cc.jj 2022-01-18 11:58:58.944991171 +0100 +++ gcc/calls.cc 2022-02-16 13:00:01.079192624 +0100 @@ -5139,6 +5139,10 @@ store_one_arg (struct arg_data *arg, rtx ARGS_SIZE_RTX (arg->locate.offset), reg_parm_stack_space, ARGS_SIZE_RTX (arg->locate.alignment_pad), false); + else if ((arg->locate.alignment_pad.var + || maybe_ne (arg->locate.alignment_pad.constant, 0)) + && !argblock) + anti_adjust_stack (ARGS_SIZE_RTX (arg->locate.alignment_pad)); /* Unless this is a partially-in-register argument, the argument is now in the stack. --- gcc/testsuite/gcc.dg/pr104558.c.jj 2022-02-16 13:24:46.986523821 +0100 +++ gcc/testsuite/gcc.dg/pr104558.c 2022-02-16 13:24:26.491808905 +0100 @@ -0,0 +1,15 @@ +/* PR middle-end/104558 */ +/* { dg-do compile } */ +/* { dg-options "-fabi-version=9" } */ + +struct __attribute__ ((aligned)) A {}; + +struct A a; + +void bar (int, int, int, int, int, int, int, struct A); + +void +foo (void) +{ + bar (0, 1, 2, 3, 4, 5, 6, a); +}