From patchwork Fri Aug 16 17:20:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1973343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=itnzCuB/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4Wlpfr4mN4z1yXZ for ; Sat, 17 Aug 2024 03:20:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC42B385E83E for ; Fri, 16 Aug 2024 17:20:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id E30C43858CDA for ; Fri, 16 Aug 2024 17:20:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E30C43858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E30C43858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723828829; cv=none; b=O+1MVDtT8QoYD/cE7x37EWpZm5LfWlEOmtqCtFI+iJn48bd7GKNA3GiKx2S3U96iEgJWk8D+g3Aa9W1c/VwXoVgUzGXh/9+QNldU5RPj50Ljlc5xkFrP/FfYPk0Y84ell8e/eP71OiRWX1IT5d6xOKn1LZROvBVhWcnwmVim6E8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723828829; c=relaxed/simple; bh=YIxySZVbRuhd6c1fSzmBOxnW0Jp2EQp844BOzJ/NvTY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mXMi4Xrr/34yWhMcxbs8qlIBWpcVEEj5BgoQkQ2SJPVqL9DCCkl36HuNiUiutIohaJASZboEA2fHL3jU+QApczRIqau61sXtvj8NOxxIbIjKhApD/Ozxl2cHt45LOZsH87n/eRmEJddfyIshdPEsMQdnBJDCOwUgHXpFE5n3hPQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-7c3d8f260easo1536004a12.1 for ; Fri, 16 Aug 2024 10:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723828826; x=1724433626; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=JnlM2I/Mr8GElwr6j/B+ECkbvv+ipL6855Jnvu2Dl3E=; b=itnzCuB/b5Z2qY0zEAnVm2LJ0dT7XI2QM+NLpGTINQfluHwNWY9KmIuBloSFTCGK7U 9P5ex33qEaT07w5vGUBcLp7wvRqUPCyHqHfUK1Ya2+aItFvNriSdrs8ZplsTAbNyEu3c Qq2KF+wWkLGtCBSsZgJjE1IQjlAm6/qJAXs8HxPcCBkzCh9Yhmsz5zp2h9XpeNnatvBn UyRNooLeDONveLjgi/r5PQQts4/3G1XRKYKa3BP1uZT5d+HiwzBdEOXhG+8bylUWJ3qo uyIG84Zl+LDL97nr1URkI4+EUXi/ULr0Fz66OWZs3XvKhQQbGixy91ts+WfqBqudUayW Mr6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723828826; x=1724433626; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JnlM2I/Mr8GElwr6j/B+ECkbvv+ipL6855Jnvu2Dl3E=; b=Dc90VR17jAL+/tkZ0ekpP2EqTaV3irHx4PQ+KkOnfQ/LpN/w0PnR6fzdk7/y6wYTLU Xo1GWh8lMBoUxzVPH1eCdQyuhPG+9gfoka4D2pMyJFmh9PlfAo2k/dvL+aG2enoh0BuP xZ/UCRQuAQcJzZBFmm61tFPhEuaycBg47PZyoKRrQHZJSpM/alGjmnVSqjyRZf++9WVd 6Vui8LrQ8r81e3pnU7syG+2HhFlOydqds5qdlKoIMiv2t5kCrEjUFMVcsiriwMTuQXJb +EoKeohgspJUbC11S/nFvJaQv4dCxA3AsbRTIhcUPRZJfsjgQEM0+cHB5Hx3nZHfVsIR O8Iw== X-Gm-Message-State: AOJu0YwPM1peQzc1kveA62wyKi3aHAMpMa/LkuLkxWqEaaxwBDLl7Btq AdKx0T1mfT8AfhWXCFl1UR5bn2jRmalCfoIkMzGfMIbTjiR5pgy4P31GQw+n X-Google-Smtp-Source: AGHT+IFFuiayd/NdKCZMYXQPjBMWHqh2FEZlmsV66KZik6u19UvSQ0dYUXUNfQHXHLqJdzxpCUhVfA== X-Received: by 2002:a17:90b:3704:b0:2c9:cf1d:1bcc with SMTP id 98e67ed59e1d1-2d3e0e3dbb9mr3696968a91.36.1723828826126; Fri, 16 Aug 2024 10:20:26 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.56.169.70]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d3d68dce02sm2911027a91.41.2024.08.16.10.20.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 10:20:25 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 61CF57403B5 for ; Fri, 16 Aug 2024 10:20:24 -0700 (PDT) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: [PATCH] Extend check-function-bodies to cover directives Date: Fri, 16 Aug 2024 10:20:24 -0700 Message-ID: <20240816172024.1648237-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3017.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, 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~incoming=patchwork.ozlabs.org@gcc.gnu.org As PR target/116174 shown, we may need to verify the directive order. Extend check-function-bodies to cover directives. * gcc.target/i386/pr116174.c: Use check-function-bodies. * lib/scanasm.exp (configure_check-function-bodies): Add an argument for fluff. Set up_config(fluff) to $fluff if not empty. (check-function-bodies): Add an optional argument for fluff and pass it to configure_check-function-bodies. Signed-off-by: H.J. Lu --- gcc/testsuite/gcc.target/i386/pr116174.c | 16 ++++++++++++++-- gcc/testsuite/lib/scanasm.exp | 17 ++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/pr116174.c b/gcc/testsuite/gcc.target/i386/pr116174.c index 8877d0b51af..75c62964d97 100644 --- a/gcc/testsuite/gcc.target/i386/pr116174.c +++ b/gcc/testsuite/gcc.target/i386/pr116174.c @@ -1,6 +1,20 @@ /* { dg-do compile { target *-*-linux* } } */ /* { dg-options "-O2 -fcf-protection=branch" } */ +/* Keep directives ('.p2align', '.cfi_startproc'). +/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\s*(?://|$)} } } */ +/* +**foo: +**... +** .cfi_startproc +** ( +** endbr64 +** | +** endbr32 +** ) +** .p2align 5 +**... +*/ char * foo (char *dest, const char *src) { @@ -8,5 +22,3 @@ foo (char *dest, const char *src) /* nothing */; return --dest; } - -/* { dg-final { scan-assembler "\t\.cfi_startproc\n\tendbr(32|64)\n" } } */ diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 42c719c512c..5165284608f 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -863,7 +863,7 @@ proc scan-lto-assembler { args } { # Set up CONFIG for check-function-bodies. -proc configure_check-function-bodies { config } { +proc configure_check-function-bodies { config fluff } { upvar $config up_config # Regexp for the start of a function definition (name in \1). @@ -890,7 +890,9 @@ proc configure_check-function-bodies { config } { } # Regexp for lines that aren't interesting. - if { [istarget nvptx*-*-*] } { + if {$fluff ne ""} then { + set up_config(fluff) $fluff + } elseif { [istarget nvptx*-*-*] } { # Skip lines beginning with '//' comments ('-fverbose-asm', for # example). set up_config(fluff) {^\s*(?://)} @@ -982,7 +984,7 @@ proc check_function_body { functions name body_regexp } { # Check the implementations of functions against expected output. Used as: # -# { dg-do { check-function-bodies PREFIX TERMINATOR[ OPTION[ SELECTOR]] } } +# { dg-do { check-function-bodies PREFIX TERMINATOR[ OPTION[ SELECTOR [FLUFF]]] } } # # See sourcebuild.texi for details. @@ -990,7 +992,7 @@ proc check-function-bodies { args } { if { [llength $args] < 2 } { error "too few arguments to check-function-bodies" } - if { [llength $args] > 4 } { + if { [llength $args] > 5 } { error "too many arguments to check-function-bodies" } @@ -1029,6 +1031,11 @@ proc check-function-bodies { args } { } } + set fluff "" + if { [llength $args] >= 5 } { + set fluff [lindex $args 4] + } + set testcase [testname-for-summary] # The name might include a list of options; extract the file name. set filename [lindex $testcase 0] @@ -1048,7 +1055,7 @@ proc check-function-bodies { args } { # (name in \1). This may be different from '$config(start)'. set start_expected {^(\S+):$} - configure_check-function-bodies config + configure_check-function-bodies config $fluff set have_bodies 0 if { [is_remote host] } { remote_upload host "$filename"