From patchwork Tue Nov 16 09:42:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1555715 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=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=uriZfP+T; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=mW4PFGmf; 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 (server2.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 4Hth1l6D6fz9sX3 for ; Tue, 16 Nov 2021 20:42:50 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F91B3857831 for ; Tue, 16 Nov 2021 09:42:48 +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 [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 5D3693858411 for ; Tue, 16 Nov 2021 09:42:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D3693858411 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 53FD82171F for ; Tue, 16 Nov 2021 09:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637055755; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=7K/h9BTb5gi81TYn2IF1MXk3m5XxA0p/NVlLSltU+ro=; b=uriZfP+TBUXbK1KQIkI/qQpr1p8tl9KipkXv/AauIi7nrqoIO8nropci4ZroVcJPcQdmq5 yxIyKkcl7PYymEj+G20VtyLnR2/ZlJgAIsEd3R8KQIP++ZQxRGJLiCrhGAK7lrZ/88AclB Q10IkB1LBkfphWgVHe68/vS1AeLDsUg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637055755; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=7K/h9BTb5gi81TYn2IF1MXk3m5XxA0p/NVlLSltU+ro=; b=mW4PFGmfpO283+Z4Vb34uB7b2WWOBFvIBQo+ae00amFnR2iRGksuVPPDsboS2KxEtsKHt+ ZehdAfuF2rF6YUAQ== Received: from suse.cz (virgil.suse.cz [10.100.13.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 42049A3B84 for ; Tue, 16 Nov 2021 09:42:35 +0000 (UTC) From: Martin Jambor To: GCC Patches Subject: [PATCH] ipa-sra: Testcase that removing a "returns_nonnull" retval works User-Agent: Notmuch/0.33.2 (https://notmuchmail.org) Emacs/27.2 (x86_64-suse-linux-gnu) Date: Tue, 16 Nov 2021 10:42:35 +0100 Message-ID: MIME-Version: 1.0 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 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, since we can now remove return values of functions with return_nonnull type attribute, I'll feel a bit safer if we can test this does not ICE when someone attempts to access a non-existent call LHS. Eventually we should probably drop the attribute when this happens. Tested on x86_64-linux, I will push it to master momentarily. Martin gcc/testsuite/ChangeLog: 2021-11-15 Martin Jambor * gcc.dg/ipa/ipa-sra-ret-nonull.c: New test. --- gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c b/gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c new file mode 100644 index 00000000000..18c13efd609 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-sra-details" } */ + +volatile void *gp; +volatile void *gq; +char buf[16]; + +__attribute__((returns_nonnull, noinline)) +static char * +foo (char *p, char *q) +{ + gq = q; + gp = p; + return q; +} + +__attribute__((returns_nonnull, noinline)) +static char * +bar (char *p, char *q) +{ + return foo (p, q) + 8; +} + +__attribute__((noipa)) +static char * +get_charp (void) +{ + return &buf[0]; +} + +int +main () +{ + char *r; + asm volatile ("" : : : "memory"); + r = bar (get_charp (), get_charp ()); + return 0; +} + +/* { dg-final { scan-ipa-dump-times "Will SKIP return." 2 "sra" } } */