From patchwork Thu Nov 14 18:37:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Malcomson X-Patchwork-Id: 1195042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513450-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ai4QQwi6"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="zPRqVDAL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="zPRqVDAL"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVbv4LKwz9sPc for ; Fri, 15 Nov 2019 05:38:17 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type:mime-version; q=dns; s=default; b=lF5W7Ztmb94GCUbSlDqCdYQGcrq0ccsfwWnyPNYWgRN7M22m2g SnIK1/tg4cmSLH/fv7v0mKZpWTm4CRTNnsEz+V8QQRup51vi+T1Ad6mEdYn887P0 5+vh0Tom1k9lMlXTos/GR+eTYzvcuTu8rAFV6O34FwBbV1dhhqY/ifu+w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type:mime-version; s= default; bh=/7t5NKI1MEM9+BcN66t7be/RKlY=; b=ai4QQwi63HCr5QK1NfVH HTsdJCEPvl0fVAQplOOzt4zB0E8cv+E8yJ5oo6WyxUMysp9oHu0wMNGZI6b5Us6q IAQuZ0SS3aWk7DSWZJcViumW60+QXiLxMC1SDBxD8g2WmvIopTpiuor8ZupH6zcn wZ2MGy4k7xal34Kmns1eMYM= Received: (qmail 110115 invoked by alias); 14 Nov 2019 18:38:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 110099 invoked by uid 89); 14 Nov 2019 18:38:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: EUR03-VE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr50087.outbound.protection.outlook.com (HELO EUR03-VE1-obe.outbound.protection.outlook.com) (40.107.5.87) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2019 18:38:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S3Pvjg5uYpaapBVVjTNclI4Sic9+Zz88JIPnF+8OXHM=; b=zPRqVDALHBHs8JEfwRe/IggeXaIl6zZhhMk+tUpY8pQY5ej28ge9wefXnuQ8b7FDd3ysYOCEUZo2UlGIhSUWhwIEDnTs+DjjTGFvQWfj+hPQyc3PE6TrhI+pSNH+vTjfWWXpCOJDYHP+7bMOCclrmwWUy0karwZsQqVB/QEDRPk= Received: from VI1PR0802CA0045.eurprd08.prod.outlook.com (2603:10a6:800:a9::31) by AM0PR08MB3715.eurprd08.prod.outlook.com (2603:10a6:208:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.20; Thu, 14 Nov 2019 18:38:02 +0000 Received: from DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by VI1PR0802CA0045.outlook.office365.com (2603:10a6:800:a9::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23 via Frontend Transport; Thu, 14 Nov 2019 18:38:02 +0000 Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT041.mail.protection.outlook.com (10.152.21.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23 via Frontend Transport; Thu, 14 Nov 2019 18:38:02 +0000 Received: ("Tessian outbound 6481c7fa5a3c:v33"); Thu, 14 Nov 2019 18:38:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 717ea1197880ba07 X-CR-MTA-TID: 64aa7808 Received: from 530765bcdf07.1 (cr-mta-lb-1.cr-mta-net [104.47.9.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id DB1FE9D2-7FBE-4B8B-841A-A42E23C6D483.1; Thu, 14 Nov 2019 18:37:57 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2057.outbound.protection.outlook.com [104.47.9.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 530765bcdf07.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 14 Nov 2019 18:37:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FG5HWRrnORyZdxvQUF/FFQY6zMDv3tALSqYfGrx1pbEBPJ9ccfd1e5+yjrKC3DZTTUh8uIfA2awuWVzB8YFiUrrUHnkGr+1ygJPmdLN4fuOG/szVQ0v74xFRyDAMvAu8sbfVr1MDDCZxfe+jAgemS3xxLevn9TatZCmyQAUU8qiIi2iQfCIdCrqGpIKE6ouDLd/RzhlLn5vJzQ9dqFHZrXK7pGr5e277lqlPgJb+ebNCRGLcn/UshfnOBzATeVHn4Olnjb3MAcbJQVD5HTg3/MWokAeLbhqeD5ib6GXavesvvIeEUAXfhMvva59ZQeiM0xOfJW+OqL4IsAoqe6KcXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S3Pvjg5uYpaapBVVjTNclI4Sic9+Zz88JIPnF+8OXHM=; b=MZaicuR7tBDvC+HTR9Q6hqCvuY47b8BoAQtq+MzrqcTq3kYW1VWQVmTjxTHANNqKzrFWFwKnkascnWnowBu0jrs9okYfwG5z+puIJn9Im3m+j9TDUG9gKxcddoPfVUqMt7CB2me1+2CmBXO90exWs73O6TrB5B6who9GyiyKna6xpgphNLtM+gJoyyGCoa7W6cv/cN2M0coW72Cm3VgFjcMt9a3/0VwusZOv1So2UBDBdeeImwTxVY2GbiA8pkhJ8VApvvQL49gDNep6EJTB2aAe9jMDMsj5d+71hgk85KrSQwbkPasw7BpbCVNMfZd8FdS8TPjdo83BKrkTgwsX+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S3Pvjg5uYpaapBVVjTNclI4Sic9+Zz88JIPnF+8OXHM=; b=zPRqVDALHBHs8JEfwRe/IggeXaIl6zZhhMk+tUpY8pQY5ej28ge9wefXnuQ8b7FDd3ysYOCEUZo2UlGIhSUWhwIEDnTs+DjjTGFvQWfj+hPQyc3PE6TrhI+pSNH+vTjfWWXpCOJDYHP+7bMOCclrmwWUy0karwZsQqVB/QEDRPk= Received: from HE1PR0802MB2251.eurprd08.prod.outlook.com (10.172.131.21) by HE1PR0802MB2332.eurprd08.prod.outlook.com (10.172.128.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.24; Thu, 14 Nov 2019 18:37:55 +0000 Received: from HE1PR0802MB2251.eurprd08.prod.outlook.com ([fe80::e120:9a38:bcf4:6075]) by HE1PR0802MB2251.eurprd08.prod.outlook.com ([fe80::e120:9a38:bcf4:6075%5]) with mapi id 15.20.2451.027; Thu, 14 Nov 2019 18:37:55 +0000 From: Matthew Malcomson To: "gcc-patches@gcc.gnu.org" CC: nd , "ian@airs.com" , "law@redhat.com" , "dmalcolm@redhat.com" , "rguenther@suse.de" Subject: [Patch] [mid-end][__RTL] Clean df state despite invalid __RTL startwith passes Date: Thu, 14 Nov 2019 18:37:55 +0000 Message-ID: Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Matthew.Malcomson@arm.com; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(396003)(136003)(376002)(366004)(346002)(199004)(54534003)(189003)(81156014)(99286004)(6116002)(26005)(81166006)(6506007)(5024004)(386003)(256004)(305945005)(7736002)(44832011)(2501003)(8676002)(25786009)(71190400001)(52116002)(71200400001)(4001150100001)(2906002)(86362001)(186003)(102836004)(9686003)(6436002)(14454004)(55016002)(7696005)(5640700003)(478600001)(4326008)(8936002)(3846002)(66066001)(66446008)(5660300002)(64756008)(66556008)(52536014)(66616009)(66476007)(74316002)(476003)(6916009)(33656002)(54906003)(316002)(486006)(66946007)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0802MB2332; H:HE1PR0802MB2251.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: J+kShkYnWTA18GzQQ/hvNC5teKJynud8s5tBZFwF6tWKZF1y1Sfz915Ea+KxrUL93I243iuVecRCuqSdMJQh3N1q1EnNGUSgwgx0n+cy/3ioBttvtBKDDBGaSqYB6xWmFWo+RCqRIqSDqWc/QCryuWvSBe5m98/R4dS3CPP5FookOcdokI3PxyUEDLIJd0CSTjuB8WYvOfQNh4DyWo5hmQh+9fHc6YM6Op4LPjE8YS/B2nFMQmYoJRD/N4cyF9hsoqSvUeNHsdnzNOwT8LadUPAi5x6JItW8HdLoD3kivVS4B/QjKXZHWDqbt5LmtlCmaobiOm4f6UMT7xl+m3m9r6EYwqFrWclf0J+kHH0V9jZTJfyNhQ8T9ecCjE+InNVVPvw4Rq3D4GnjjU0MWvxMh8Do0lKA/dtLapdGaG8PqkY/ndel/bCbRkvtZosOS2xl x-ms-exchange-transport-forked: True MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Matthew.Malcomson@arm.com; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bc6c714e-ca38-4e1b-b58f-08d76931c366 X-IsSubscribed: yes Hi there, When compiling an __RTL function that has an invalid "startwith" pass we currently don't run the dfinish cleanup pass. This means we ICE on the next function. This change ensures that all state is cleaned up for the next function to run correctly. As an example, before this change the following code would ICE when compiling the function `foo2` because the "peephole2" pass is not run at optimisation level -O0. When compiled with ./aarch64-none-linux-gnu-gcc -O0 -S missed-pass-error.c -o test.s ``` int __RTL (startwith ("peephole2")) badfoo () { (function "badfoo" (insn-chain (block 2 (edge-from entry (flags "FALLTHRU")) (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) (cinsn 101 (set (reg:DI x19) (reg:DI x0))) (cinsn 10 (use (reg/i:SI x19))) (edge-to exit (flags "FALLTHRU")) ) ;; block 2 ) ;; insn-chain ) ;; function "foo2" } int __RTL (startwith ("final")) foo2 () { (function "foo2" (insn-chain (block 2 (edge-from entry (flags "FALLTHRU")) (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) (cinsn 101 (set (reg:DI x19) (reg:DI x0))) (cinsn 10 (use (reg/i:SI x19))) (edge-to exit (flags "FALLTHRU")) ) ;; block 2 ) ;; insn-chain ) ;; function "foo2" } ``` Now it silently ignores the __RTL function and successfully compiles foo2. regtest done on aarch64 regtest done on x86_64 OK for trunk? gcc/ChangeLog: 2019-11-14 Matthew Malcomson * passes.c (should_skip_pass_p): Always run "dfinish". gcc/testsuite/ChangeLog: 2019-11-14 Matthew Malcomson * gcc.dg/rtl/aarch64/missed-pass-error.c: New test. ############### Attachment also inlined for ease of reply ############### diff --git a/gcc/passes.c b/gcc/passes.c index d86af115ecb16fcab6bfce070f1f3e4f1d90ce71..258f85ab4f8a1519b978b75dfa67536d2eacd106 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2375,7 +2375,8 @@ should_skip_pass_p (opt_pass *pass) return false; /* Don't skip df init; later RTL passes need it. */ - if (strstr (pass->name, "dfinit") != NULL) + if (strstr (pass->name, "dfinit") != NULL + || strstr (pass->name, "dfinish") != NULL) return false; if (!quiet_flag) diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/missed-pass-error.c b/gcc/testsuite/gcc.dg/rtl/aarch64/missed-pass-error.c new file mode 100644 index 0000000000000000000000000000000000000000..2f02ca9d0c40b372d86b24009540e157ed1a8c59 --- /dev/null +++ b/gcc/testsuite/gcc.dg/rtl/aarch64/missed-pass-error.c @@ -0,0 +1,45 @@ +/* { dg-do compile { target aarch64-*-* } } */ +/* { dg-additional-options "-O0" } */ + +/* + When compiling __RTL functions the startwith string can be either incorrect + (i.e. not matching a pass) or be unused (i.e. can refer to a pass that is + not run at the current optimisation level). + + Here we ensure that the state clean up is still run, so that functions other + than the faulty one can still be compiled. + */ + +int __RTL (startwith ("peephole2")) badfoo () +{ +(function "badfoo" + (insn-chain + (block 2 + (edge-from entry (flags "FALLTHRU")) + (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) + (cinsn 101 (set (reg:DI x19) (reg:DI x0))) + (cinsn 10 (use (reg/i:SI x19))) + (edge-to exit (flags "FALLTHRU")) + ) ;; block 2 + ) ;; insn-chain +) ;; function "foo2" +} + +/* Compile a valid __RTL function to test state from the "dfinit" pass has been + cleaned with the "dfinish" pass. */ + +int __RTL (startwith ("final")) foo2 () +{ +(function "foo2" + (insn-chain + (block 2 + (edge-from entry (flags "FALLTHRU")) + (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) + (cinsn 101 (set (reg:DI x19) (reg:DI x0))) + (cinsn 10 (use (reg/i:SI x19))) + (edge-to exit (flags "FALLTHRU")) + ) ;; block 2 + ) ;; insn-chain +) ;; function "foo2" +} + diff --git a/gcc/passes.c b/gcc/passes.c index d86af115ecb16fcab6bfce070f1f3e4f1d90ce71..258f85ab4f8a1519b978b75dfa67536d2eacd106 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2375,7 +2375,8 @@ should_skip_pass_p (opt_pass *pass) return false; /* Don't skip df init; later RTL passes need it. */ - if (strstr (pass->name, "dfinit") != NULL) + if (strstr (pass->name, "dfinit") != NULL + || strstr (pass->name, "dfinish") != NULL) return false; if (!quiet_flag) diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/missed-pass-error.c b/gcc/testsuite/gcc.dg/rtl/aarch64/missed-pass-error.c new file mode 100644 index 0000000000000000000000000000000000000000..2f02ca9d0c40b372d86b24009540e157ed1a8c59 --- /dev/null +++ b/gcc/testsuite/gcc.dg/rtl/aarch64/missed-pass-error.c @@ -0,0 +1,45 @@ +/* { dg-do compile { target aarch64-*-* } } */ +/* { dg-additional-options "-O0" } */ + +/* + When compiling __RTL functions the startwith string can be either incorrect + (i.e. not matching a pass) or be unused (i.e. can refer to a pass that is + not run at the current optimisation level). + + Here we ensure that the state clean up is still run, so that functions other + than the faulty one can still be compiled. + */ + +int __RTL (startwith ("peephole2")) badfoo () +{ +(function "badfoo" + (insn-chain + (block 2 + (edge-from entry (flags "FALLTHRU")) + (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) + (cinsn 101 (set (reg:DI x19) (reg:DI x0))) + (cinsn 10 (use (reg/i:SI x19))) + (edge-to exit (flags "FALLTHRU")) + ) ;; block 2 + ) ;; insn-chain +) ;; function "foo2" +} + +/* Compile a valid __RTL function to test state from the "dfinit" pass has been + cleaned with the "dfinish" pass. */ + +int __RTL (startwith ("final")) foo2 () +{ +(function "foo2" + (insn-chain + (block 2 + (edge-from entry (flags "FALLTHRU")) + (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) + (cinsn 101 (set (reg:DI x19) (reg:DI x0))) + (cinsn 10 (use (reg/i:SI x19))) + (edge-to exit (flags "FALLTHRU")) + ) ;; block 2 + ) ;; insn-chain +) ;; function "foo2" +} +