From patchwork Fri Dec 10 10:29:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 48765 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 958953857C59 for ; Fri, 10 Dec 2021 10:30:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id E748F3858D35 for ; Fri, 10 Dec 2021 10:29:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E748F3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=sFueiMJXXpNETXRU4jydnXL4D6a7sxHcIo0xjq6yvds=; b=TTuXCcNzJ1Sg8hBR1VWW3bfy63 FXlTf7FgBko4PExf7C+cbNcgEIts7ynON8spfSG0xj1WXOCmPFnUG4LAkj1k8lWmOsAeVGSQlas1v PE7rKBqGPMvr/ia+f9ja10gLrrNe2WLd8/yNBxpoo+XivhuoCM+DqGMXN+5Zz6v07T6IuyMBr9Pvu RHTOA7Utotdm0ieWa31RAqjzaUWdVlHuApJ2ree1sk2g7RQEAq7BxwK5wBVFoTDZG+f4WMyU/jb+U tj5DN9bvd99ZSqG0jcBX47CUMTXUCDTRPmCLFl1gth12ykYuueThv8zqlgypWgiCkVRqMmzZfMOOz 9MgovQxQ==; Received: from [185.62.158.67] (port=59993 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mvd9r-0003rh-9d; Fri, 10 Dec 2021 05:29:43 -0500 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] PR ipa/103601: ICE compiling CSiBE in ipa-modref's insert_kill Date: Fri, 10 Dec 2021 10:29:42 -0000 Message-ID: <001e01d7edb0$d89c2de0$89d489a0$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdftsAQQBWRcL+bCR86zF76CL9Xyug== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.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 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: , Cc: 'Jan Hubicka' Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch fixes PR ipa/103061 which is P1 regression that shows up as an ICE in ipa-modref-tree.c's insert_kill when compiling the CSiBE benchmark. I believe the underlying cause is that the new kill tracking functionality wasn't anticipating memory accesses that are zero bits wide!?. The failing source code (test case) contains the unusual lines: typedef struct { } spinlock_t; and q->lock = (spinlock_t) { }; Making spinlock_t larger, or removing the assignment work around the issue. The one line patch below to useful_for_kill_p teaches IPA that a memory write is only useful as a "kill" if it is more than zero bits wide. In theory, the existing known_size_p (size) test is now redundant, as poly_int64 currently uses the value -1 for unknown size values, but the proposed change makes the semantics clear, and defends against possible future changes in representation [but I'm happy to change this]. This patch has been tested on x86_64-pc-linux-gnu with a make bootstrap and make -k check with no new failures. Ok for mainline? 2021-12-10 Roger Sayle gcc/ChangeLog PR ipa/103601 * ipa-modref-tree.h (useful_for_kill_p): Zero width accesses aren't useful for kill tracking. gcc/testsuite/ChangeLog PR ipa/103601 * gcc.dg/ipa/pr103601.c: New test case. Thanks in advance, Roger diff --git a/gcc/ipa-modref-tree.h b/gcc/ipa-modref-tree.h index 35190c2..4ad556f 100644 --- a/gcc/ipa-modref-tree.h +++ b/gcc/ipa-modref-tree.h @@ -87,7 +87,8 @@ struct GTY(()) modref_access_node { return parm_offset_known && parm_index != MODREF_UNKNOWN_PARM && parm_index != MODREF_RETSLOT_PARM && known_size_p (size) - && known_eq (max_size, size); + && known_eq (max_size, size) + && known_gt (size, 0); } /* Dump range to debug OUT. */ void dump (FILE *out); diff --git a/gcc/testsuite/gcc.dg/ipa/pr103601.c b/gcc/testsuite/gcc.dg/ipa/pr103601.c new file mode 100644 index 0000000..7bdb5e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr103601.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgnu89-inline" } */ + +typedef struct { } spinlock_t; +struct list_head { + struct list_head *next, *prev; +}; +struct __wait_queue_head { + spinlock_t lock; + struct list_head task_list; +}; +typedef struct __wait_queue_head wait_queue_head_t; +static inline void init_waitqueue_head(wait_queue_head_t *q) +{ + q->lock = (spinlock_t) { }; + do { (&q->task_list)->next = (&q->task_list); (&q->task_list)->prev = (&q->task_list); } while (0); +} +struct timer_list { + void (*function)(unsigned long); +}; +struct rpc_task { + struct timer_list tk_timer; + wait_queue_head_t tk_wait; +}; +static void +rpc_run_timer(struct rpc_task *task) +{ +} +inline void +rpc_init_task(struct rpc_task *task) +{ + task->tk_timer.function = (void (*)(unsigned long)) rpc_run_timer; + init_waitqueue_head(&task->tk_wait); +} +