From patchwork Thu Aug 15 12:55:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1972772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wl4qk1wMZz1yNr for ; Thu, 15 Aug 2024 22:56:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D08663858424 for ; Thu, 15 Aug 2024 12:55:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id AC08E3858D29 for ; Thu, 15 Aug 2024 12:55:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC08E3858D29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AC08E3858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723726541; cv=none; b=Fm7+vsU5S1VJTKlj5kPWEEJzNztfvchOK9s6636n6Y75iMQOr5RYanI+pGDZDUsEQoyyEvD5NF7noPQZ3Vl8o/l++EkYDZfKSi/7YK7UY6wXCkXVbVweZYcoAmuNC8W+BgW6UXQXQ02FxpGZt7NSutVAs+7HY23d1XmGuxEL184= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723726541; c=relaxed/simple; bh=mQo4+4p6yXYpIQwlFvSqF+6zysVHxTjavmzjicK+QBM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=WjHsuYeKkkfSIRGu2oHfwcw2AsKtk5Ew7MEBgh2tVRARG/Ox/6DWOsfRY5dGDV7901CVz6sIb6370RMmOHpdvsSNSoHJQIyEcxphWHXmMllkw/bhzWREZeKe6fk00Gr7EDaJL50kM/pTayljRRMGe8mngZhshTwmzPO+/SPdamg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3B80614BF; Thu, 15 Aug 2024 05:56:04 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D17D63F6A8; Thu, 15 Aug 2024 05:55:37 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org,alex.coplan@arm.com, richard.sandiford@arm.com Cc: alex.coplan@arm.com Subject: [PATCH] testsuite: Reduce cut-&-paste in scanltranstree.exp Date: Thu, 15 Aug 2024 13:55:36 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Spam-Status: No, score=-19.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, 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~incoming=patchwork.ozlabs.org@gcc.gnu.org scanltranstree.exp defines some LTO wrappers around standard non-LTO scanners. Four of them are cut-&-paste variants of one another, so this patch generates them from a single template. It also does the same for scan-ltrans-tree-dump-times, so that other *-times scanners can be added easily in future. The scanners seem to be lightly used. gcc.dg/ipa/ipa-icf-38.c uses scan-ltrans-tree-dump{,-not} and libgomp.c/declare-variant-1.c uses scan-ltrans-tree-dump-{not,times}. Nothing currently seems to use scan-ltrans-tree-dump-dem*. Tested on the files above so far. Surprisingly, it worked first time, but I tested that deliberately introduced mistakes were flagged. (That's my story anyway.) OK if it passes full testing on aarch64-linux-gnu & x86_64-linux-gnu? Richard gcc/testsuite/ * lib/scanltranstree.exp: Redefine the routines using two templates. --- gcc/testsuite/lib/scanltranstree.exp | 186 +++++++++------------------ 1 file changed, 62 insertions(+), 124 deletions(-) diff --git a/gcc/testsuite/lib/scanltranstree.exp b/gcc/testsuite/lib/scanltranstree.exp index 79f05f0ffed..bc6e02dc369 100644 --- a/gcc/testsuite/lib/scanltranstree.exp +++ b/gcc/testsuite/lib/scanltranstree.exp @@ -19,130 +19,68 @@ load_lib scandump.exp -# Utility for scanning compiler result, invoked via dg-final. -# Call pass if pattern is present, otherwise fail. -# -# Argument 0 is the regexp to match -# Argument 1 is the name of the dumped tree pass -# Argument 2 handles expected failures and the like -proc scan-ltrans-tree-dump { args } { - - if { [llength $args] < 2 } { - error "scan-ltrans-tree-dump: too few arguments" - return - } - if { [llength $args] > 3 } { - error "scan-ltrans-tree-dump: too many arguments" - return - } - if { [llength $args] >= 3 } { - scan-dump "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" ".ltrans0.ltrans" \ - [lindex $args 2] - } else { - scan-dump "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" ".ltrans0.ltrans" - } -} - -# Call pass if pattern is present given number of times, otherwise fail. -# Argument 0 is the regexp to match -# Argument 1 is number of times the regexp must be found -# Argument 2 is the name of the dumped tree pass -# Argument 3 handles expected failures and the like -proc scan-ltrans-tree-dump-times { args } { - - if { [llength $args] < 3 } { - error "scan-ltrans-tree-dump-times: too few arguments" - return - } - if { [llength $args] > 4 } { - error "scan-ltrans-tree-dump-times: too many arguments" - return - } - if { [llength $args] >= 4 } { - scan-dump-times "ltrans-tree" [lindex $args 0] [lindex $args 1] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 2]" \ - ".ltrans0.ltrans" [lindex $args 3] - } else { - scan-dump-times "ltrans-tree" [lindex $args 0] [lindex $args 1] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 2]" ".ltrans0.ltrans" - } +# The first item in the list is an LTO equivalent of the second item +# in the list; see the documentation of the second item for details. +foreach { name scan type suffix } { + scan-ltrans-tree-dump scan-dump ltrans-tree t + scan-ltrans-tree-dump-not scan-dump-not ltrans-tree t + scan-ltrans-tree-dump-dem scan-dump-dem ltrans-tree t + scan-ltrans-tree-dump-dem-not scan-dump-dem-not ltrans-tree t +} { + eval [string map [list @NAME@ $name \ + @SCAN@ $scan \ + @TYPE@ $type \ + @SUFFIX@ $suffix] { + proc @NAME@ { args } { + if { [llength $args] < 2 } { + error "@NAME@: too few arguments" + return + } + if { [llength $args] > 3 } { + error "@NAME@: too many arguments" + return + } + if { [llength $args] >= 3 } { + @SCAN@ @TYPE@ [lindex $args 0] \ + "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 1]" \ + ".ltrans0.ltrans" \ + [lindex $args 2] + } else { + @SCAN@ @TYPE@ [lindex $args 0] \ + "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 1]" \ + ".ltrans0.ltrans" + } + } + }] } -# Call pass if pattern is not present, otherwise fail. -# -# Argument 0 is the regexp to match -# Argument 1 is the name of the dumped tree pass -# Argument 2 handles expected failures and the like -proc scan-ltrans-tree-dump-not { args } { - - if { [llength $args] < 2 } { - error "scan-ltrans-tree-dump-not: too few arguments" - return - } - if { [llength $args] > 3 } { - error "scan-ltrans-tree-dump-not: too many arguments" - return - } - if { [llength $args] >= 3 } { - scan-dump-not "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" ".ltrans0.ltrans" \ - [lindex $args 2] - } else { - scan-dump-not "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" ".ltrans0.ltrans" - } -} - -# Utility for scanning demangled compiler result, invoked via dg-final. -# Call pass if pattern is present, otherwise fail. -# -# Argument 0 is the regexp to match -# Argument 1 is the name of the dumped tree pass -# Argument 2 handles expected failures and the like -proc scan-ltrans-tree-dump-dem { args } { - - if { [llength $args] < 2 } { - error "scan-ltrans-tree-dump-dem: too few arguments" - return - } - if { [llength $args] > 3 } { - error "scan-ltrans-tree-dump-dem: too many arguments" - return - } - if { [llength $args] >= 3 } { - scan-dump-dem "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" ".ltrans0.ltrans" \ - [lindex $args 2] - } else { - scan-dump-dem "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" ".ltrans0.ltrans" - } -} - -# Call pass if demangled pattern is not present, otherwise fail. -# -# Argument 0 is the regexp to match -# Argument 1 is the name of the dumped tree pass -# Argument 2 handles expected failures and the like -proc scan-ltrans-tree-dump-dem-not { args } { - - if { [llength $args] < 2 } { - error "scan-ltrans-tree-dump-dem-not: too few arguments" - return - } - if { [llength $args] > 3 } { - error "scan-ltrans-tree-dump-dem-not: too many arguments" - return - } - if { [llength $args] >= 3 } { - scan-dump-dem-not "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" \ - ".ltrans0.ltrans" [lindex $args 2] - } else { - scan-dump-dem-not "ltrans-tree" [lindex $args 0] \ - "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 1]" \ - ".ltrans0.ltrans" - } +# The first item in the list is an LTO equivalent of the second item +# in the list; see the documentation of the second item for details. +foreach { name scan type suffix } { + scan-ltrans-tree-dump-times scan-dump-times ltrans-tree t +} { + eval [string map [list @NAME@ $name \ + @SCAN@ $scan \ + @TYPE@ $type \ + @SUFFIX@ $suffix] { + proc @NAME@ { args } { + if { [llength $args] < 3 } { + error "@NAME@: too few arguments" + return + } + if { [llength $args] > 4 } { + error "@NAME@: too many arguments" + return + } + if { [llength $args] >= 4 } { + @SCAN@ "@TYPE@" [lindex $args 0] [lindex $args 1] \ + "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 2]" \ + ".ltrans0.ltrans" [lindex $args 3] + } else { + @SCAN@ "@TYPE@" [lindex $args 0] [lindex $args 1] \ + "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 2]" \ + ".ltrans0.ltrans" + } + } + }] }