From patchwork Mon Nov 13 13:38:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 164491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1206008vqg; Mon, 13 Nov 2023 05:39:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5VHKQB0N2cnrBMnPtggI1vUWxVA9fQdvXtKaeb8x3BXcNSpT8zvFvbin2fzPcMVP42pKa X-Received: by 2002:a05:620a:24c1:b0:774:3147:4251 with SMTP id m1-20020a05620a24c100b0077431474251mr8368402qkn.6.1699882748932; Mon, 13 Nov 2023 05:39:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699882748; cv=pass; d=google.com; s=arc-20160816; b=a6FUc0eyavwTd0mKHtzkKuk6y8J5XRTMXLa/5HAE74rnWL0ymRm+c3p32+ucaO08LQ Auv0AoZGvgL7GSldKAWWB3dWGEhqXL/S/jZbLlYK5XB8WLJ8AFOKlSFeY/JehpU+IzZh Youc3AP7o+7U+4pDg/Kvv+1q4+ytehDoIXw7FIUlPfN8guo69HYMVNxqfgmkcxUrLckR Q38pdLffX88oH56dHGspMdQE9HnL8DWLWTR06uE/SpQSEkcID5o7ITp9Fu4Gp5comrgC c2pDqO8E15F52sVFmaic8iL1iAh/ZvDaTnknRoiuXtfNB7X+6UnqeN7XxBF/tuSTbdsp dOTw== 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=Vs43OqDVf9VjeYdPgKoTMUgYKpMywz6Jj0UVqBrx0Xw=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=VkhF39DBn1D6ekFASRDHelka+PMctiPqFQFjQCnzyGQEIIV5lIaGBH1rRX4O1cXmqK a/ccUeVKZFzHj8iQN7rxbPj3NmHxjlh8nhWOjpB4MmNsrf1Z+1NC+IxlRICnKEE498/h DO+pdqbq8NbKGtDuKkMvoL7gj6n48orfh7KNe4Ww9YzKRUhs9lbN3JDxcTa4GGqkQ9PB NOq70C7ur0dFjLRF1DoAvO83TKccgyCvIJYkcGc0thSdFvTLgI6560hbnV4//94tIM8Q tJu6Pio19O7lSg7ubyRzu5CLWvMQSMcml/9UQFCa+gglgkYuBqxnlLUW8i3KqnPPHjaO PlUw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=XENHLf3B; 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 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id bs14-20020a05620a470e00b0076da008f6ccsi4616404qkb.288.2023.11.13.05.39.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 05:39:08 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=XENHLf3B; 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 8.43.85.97 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 AD2CB3841901 for ; Mon, 13 Nov 2023 13:39:08 +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:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 1BA2C38319E3 for ; Mon, 13 Nov 2023 13:38:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BA2C38319E3 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 1BA2C38319E3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699882726; cv=none; b=QcWQphqpT5aScQmUhKr1/1QULudGG1nR4+pNTRzVwA+r1LlxD5u42EEsIJDhrQRCWoamb/DVz+ZDepgzncqHtjlokGfGlQzcHBrHxSHigYsz87juCXfnjMN/FvUQs9Q6bzVeF8pdcFW6+knScF91sYYLzXZ+M/kEn4wKyN5ZUE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699882726; c=relaxed/simple; bh=S4vKgLzawTFbbX9E4pbwHHaU1+ZcXe4xfdcmo7a2CcQ=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version: Message-Id; b=pnFfgeVPFVEwmMFCaDtJ/ABubAqf0kfER72hwVR6mJH/YHX95KsJ85H6Lcca2kjGcpi9DnPANVor8AXCBNPZYNjME8uDuIY6Q4FlTYp/TPWMfmhIZVV+LQEdDIdVHcYDQxCTW/Of81zo5dEc1NrY1JCiUcXs4YiM5EzVL/SojYY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2B41C21903 for ; Mon, 13 Nov 2023 13:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1699882724; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Vs43OqDVf9VjeYdPgKoTMUgYKpMywz6Jj0UVqBrx0Xw=; b=XENHLf3BkeLxhIrWcQB8pbgOEycf3SClhzuDJ24NnyAq/R/82330EOMFw0TK1fxBLdkMLu qpz3bElgGiWWdLWXKnYF2/h22APITCebpSyr+55+NuXsBLKJZqGFubnFwVEekrWJWRBseY VFQdxHhwxtDCv4hB3D9/glrg+EqxKh8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1699882724; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=Vs43OqDVf9VjeYdPgKoTMUgYKpMywz6Jj0UVqBrx0Xw=; b=8GonRYfanGTHNbWWAqOi0RNwHYvVjvXv0l+NrjaCbECl51Hk0EXsi4Zg9MlkJXNvXSh1vQ V/1LKyMrjLP73/Dw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 16AD213398 for ; Mon, 13 Nov 2023 13:38:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +odzBOQmUmUFEAAAMHmgww (envelope-from ) for ; Mon, 13 Nov 2023 13:38:44 +0000 Date: Mon, 13 Nov 2023 14:38:43 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] middle-end/112487 - inline and parameter mismatch MIME-Version: 1.0 Message-Id: <20231113133844.16AD213398@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.2 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: 1782456253070345786 X-GMAIL-MSGID: 1782456253070345786 When passing an aggregate to a implicitly declared function that's later declared as receiving a register type we can run into a sanity assert that cannot hold for such gross mismatches. Instead of asserting avoid emitting a debug temp that's invalid. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR middle-end/112487 * tree-inline.cc (setup_one_parameter): When the parameter is unused only insert a debug bind when there's not a gross mismatch in value and declared parameter type. Do not assert there effectively isn't. * gcc.dg/torture/pr112487.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr112487.c | 18 ++++++++++++++++++ gcc/tree-inline.cc | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr112487.c diff --git a/gcc/testsuite/gcc.dg/torture/pr112487.c b/gcc/testsuite/gcc.dg/torture/pr112487.c new file mode 100644 index 00000000000..bc2838ee3eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr112487.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-w -std=gnu89" } */ + +struct A { char i; }; +struct B { + struct C *p; + struct A *q; +}; +struct C { struct B a[1]; }; +struct T { struct U *ptr; }; + +volatile struct T v; +void f1(volatile struct T v) { f2(v); } +void f2(volatile struct T *const v) { } +void bar() { + struct U *ptr; + f1(v); +} diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index 00d05102e7a..0b14118b94b 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -3562,7 +3562,11 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, it. */ if (optimize && gimple_in_ssa_p (cfun) && !def && is_gimple_reg (p)) { - gcc_assert (!value || !TREE_SIDE_EFFECTS (value)); + /* When there's a gross type mismatch between the passed value + and the declared argument type drop it on the floor and do + not bother to insert a debug bind. */ + if (value && !is_gimple_reg_type (TREE_TYPE (value))) + return NULL; return insert_init_debug_bind (id, bb, var, rhs, NULL); }