From patchwork Wed Nov 8 16:00:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joern Rennecke X-Patchwork-Id: 163118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp1070319vqo; Wed, 8 Nov 2023 09:28:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkz29YTN42RfukVoC2dGTpKjIzZ3AABzqB4Ar2yliQ8d263kKZrm5DEmc73qS1CKKNM3Cl X-Received: by 2002:a05:6214:2303:b0:65d:475a:a2f6 with SMTP id gc3-20020a056214230300b0065d475aa2f6mr2507844qvb.40.1699464534944; Wed, 08 Nov 2023 09:28:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699464534; cv=pass; d=google.com; s=arc-20160816; b=p5I6aHfGMCutC21I1S8Y69nm2rePdl0v4aOSWyBXNMVu3qA3V73PzLJpy7IGmHHPa0 +cAYGNQL/LwoYMux4Lme+Xt0thNLekhiZVMYu/uKDUVtwXutncp0gpumexwCWKZRP0dU NG1Y2zXtUl0Ghr5jbJgPpFNFRK6KN9j9hQOx8b3+BfKCwRySYS1LL7f8ocxDbhB+74Sb CYoixw1GVJqvUF2Sz2Fk+3tkZexJ+SjS7xLAb8hUoKfiBp2JWg4xOKmn76c9vMg7VHEC 0gRSOqerJUfSfUvePnoy7sVmLxmhpV/B+duaNAi6HOMviMRu/5ouAx/SdlW2/25yuE5M z5Iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:subject:message-id:date :from:in-reply-to:references:mime-version:dkim-signature:arc-filter :dmarc-filter:delivered-to; bh=95ZXQdh4rx3L0ZTLSLhA3LNJ9NvNQ0FKJlsvjiDWxOI=; fh=mKv0lzV+Aua5xN3uzS9jd2RQWEj4gm1u6DLmWWm0QUo=; b=Nh1ES8GOdxA3zOdSsSe5k4RKQLlQOEG2ZFE9wo+7NofdM6Y7IxmCextgRnJXC54u21 Bdb26r3OJiFNfjnzumuRqBQ4CbbWMGvITSpOQJWIp5AX/WEsarayUosm9vOyRvkQy86l Pz7qPBYOGmH5PO9PO7jTxd2TJ4Tc+r9PJJMblVhsk1W7TgLuDv5VKzYYSMWb/lpBmsW5 Mrk/G/t5qn045nyIItrMDzDGqs9M4zYwjf7iJQQq4fVSOxayiSa7zRJ1kOmtg6i02T6L 4OaUtB3W/thf1BTFJv+6wqymQgwu9ClCDY4MSFaRj9mp12kOGIEX3jYE+2r0B+18/y54 Mvyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=UjzyBrlV; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id dk19-20020a056214093300b0064f6ab4d034si1520338qvb.512.2023.11.08.09.28.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 09:28:54 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=UjzyBrlV; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A26373836E8A for ; Wed, 8 Nov 2023 16:01:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 86F9B3858407 for ; Wed, 8 Nov 2023 16:01:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86F9B3858407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 86F9B3858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699459273; cv=none; b=KTI8EcqQ7fp9HraAl1Qn/wfjllyL4MOVV0s2OilqexSC/gR2GiiGICyGvpQYRQoUiRDrjiII+T/cOopa8gLSQUqfHPvxT2cjTHuIx/kMTtarWZ5lPy3mmTXJE15tnt+spbXOX7o+wh2cYzEw67CzLjqKZSDJOu9VPz7T1m20C7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699459273; c=relaxed/simple; bh=exUnorqcktQ9fgBzS91+JdnV2mzjM3xWno/+2XXRqus=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=qM+Wx9bmWtQuooRnM+lKHJWZSFKXBxpcVM+/FtqFL5tSQLKPr+4or2RkXXwaTRAX61rNRuL67tIJWeCvYDpuKOIg0c7bpUolSrZSP8qJUUBqVGKYnJi/xMp6m2C/UF2NAv66w94dKAcoRx9nLOMAZ9deIt61hijkEL44H16vyYY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5b8f68ba4e5so4521244a12.1 for ; Wed, 08 Nov 2023 08:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1699459270; x=1700064070; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=95ZXQdh4rx3L0ZTLSLhA3LNJ9NvNQ0FKJlsvjiDWxOI=; b=UjzyBrlVKd0JTM7X7ZiN3iBL9g1uZ4KPmgpThpKscyZ0K48PoCs2uUzLFoIkHsEK5T JPmL32/KofHPkNiEpCO6/b4Tzwz53UvyfUkWg5RXy8tEjMybnzYewWNE+/6Jo3jWWuG+ HL/+TYUtEDMCH1dXN5Fh1XD6k22+4X8X1rxY48gTEV/sEE11AIMO2zjDt4V0jnuxDz+U OqGgSfpQJ70naLTYDE1PkGDcSFgduSx2eKol3zlN6VMsN5lN91koqhXBMO1iv/zWcTBo a7oJPGy9m1+2+cSTYQK/njor6yzsHyGGUucxPwVlLfwIz4moID8YFcVoCx2vcx0Pqk09 MpKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699459270; x=1700064070; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=95ZXQdh4rx3L0ZTLSLhA3LNJ9NvNQ0FKJlsvjiDWxOI=; b=XodRjDDSfw0cteJoLt6Oid0NjUSl7CXae7SxNhOcPJ3itG5OWf3EapUp129s4nd7Cq nJ1KHJWVDhrKq8VFOOpDNG35TEa75GILFMabqomFc+CQGM0keJbOP2zL+cxt0J/dp8Kf KBe7Y3OhJ0YZBEif3n9tO2aWHy8QULTQ9yMbxVX7pMGiV/egIQir2MC9RKpKRY93IPka g4yLcNDsRPf9Z/ie3MOb7Bm8w29wcV9aXuYMdpP5rHYwBJZPqPhkVY3fz+pPW165w+n+ +j0je0/GK69fCFWIzMcB7CFQGuCuvEhPgfXQa4mpzMp5z8/AyR5O1IUR8csyBCIkGvog Mlng== X-Gm-Message-State: AOJu0YwVEC0K9SXxlPQwadG7wEkLfszG0JTPkemOBe6wByUxgEXWDlpZ nZmedUfJZ6wPa/F9LCMoUTpAHU3gdSSvXASI27X3JQ== X-Received: by 2002:a17:90b:4b86:b0:280:1695:7b5 with SMTP id lr6-20020a17090b4b8600b00280169507b5mr2012187pjb.12.1699459270564; Wed, 08 Nov 2023 08:01:10 -0800 (PST) MIME-Version: 1.0 References: <2501e6a4-6f02-429f-8497-226a6b22403c@gmail.com> In-Reply-To: From: Joern Rennecke Date: Wed, 8 Nov 2023 16:00:58 +0000 Message-ID: Subject: RFA: make scan-assembler* ignore LTO sections (Was: Re: committed [RISC-V]: Harden test scan patterns) To: Jeff Law Cc: Vineet Gupta , GCC Patches X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782017723803043891 X-GMAIL-MSGID: 1782017723803043891 On Fri, 29 Sept 2023 at 14:54, Jeff Law wrote: > ... Joern can you post a follow-up manual twiddle so > that other ports can follow your example and avoid this problem? > > THanks, > > jeff The attached patch makes the scan-assembler* directives ignore the LTO sections. Regression tested (using QEMU) for riscv-sim riscv-sim/-march=rv32gcv_zfh/-mabi=ilp32d/-ftree-vectorize/--param=riscv-autovec-preference=scalable riscv-sim/-march=rv32imac/-mabi=ilp32 riscv-sim/-march=rv64gcv_zfh_zvfh_zba_zbb_zbc_zicond_zicboz_zawrs/-mabi=lp64d/-ftree-vectorize/--param=riscv-autovec-preference=scalable riscv-sim/-march=rv64imac/-mabi=lp64 2023-11-08 Joern Rennecke gcc/testsuite/ * lib/scanasm.exp (scan-assembler-times): Disregard LTO sections. (scan-assembler-dem, scan-assembler-dem-not): Likewise. (dg-scan): Likewise, if name starts with scan-assembler. (scan-raw-assembler): New proc. * gcc.dg/pr61868.c: Use scan-raw-assembler. * gcc.dg/scantest-lto.c: New test. gcc/ * doc/sourcebuild.texi (Scan the assembly output): Document change. diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 8bf701461ec..5a34a10e6c2 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -3276,21 +3276,28 @@ Passes if @var{regexp} does not match text in the file generated by @table @code @item scan-assembler @var{regex} [@{ target/xfail @var{selector} @}] -Passes if @var{regex} matches text in the test's assembler output. +Passes if @var{regex} matches text in the test's assembler output, +excluding LTO sections. + +@item scan-raw-assembler @var{regex} [@{ target/xfail @var{selector} @}] +Passes if @var{regex} matches text in the test's assembler output, +including LTO sections. @item scan-assembler-not @var{regex} [@{ target/xfail @var{selector} @}] -Passes if @var{regex} does not match text in the test's assembler output. +Passes if @var{regex} does not match text in the test's assembler output, +excluding LTO sections. @item scan-assembler-times @var{regex} @var{num} [@{ target/xfail @var{selector} @}] Passes if @var{regex} is matched exactly @var{num} times in the test's -assembler output. +assembler output, excluding LTO sections. @item scan-assembler-dem @var{regex} [@{ target/xfail @var{selector} @}] -Passes if @var{regex} matches text in the test's demangled assembler output. +Passes if @var{regex} matches text in the test's demangled assembler output, +excluding LTO sections. @item scan-assembler-dem-not @var{regex} [@{ target/xfail @var{selector} @}] Passes if @var{regex} does not match text in the test's demangled assembler -output. +output, excluding LTO sections. @item scan-assembler-symbol-section @var{functions} @var{section} [@{ target/xfail @var{selector} @}] Passes if @var{functions} are all in @var{section}. The caller needs to diff --git a/gcc/testsuite/gcc.dg/pr61868.c b/gcc/testsuite/gcc.dg/pr61868.c index 4a7e8f6ae2d..52ab7838643 100644 --- a/gcc/testsuite/gcc.dg/pr61868.c +++ b/gcc/testsuite/gcc.dg/pr61868.c @@ -7,4 +7,4 @@ int main () foo (100); return 0; } -/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */ +/* { dg-final { scan-raw-assembler "\.gnu\.lto.*.12345" } } */ diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 5df80325dff..16b5198d38b 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -79,6 +79,12 @@ proc dg-scan { name positive testcase output_file orig_args } { } set text [read $fd] close $fd + if { [string compare -length 14 $name scan-assembler] == 0 } { + # Remove LTO sections. + # ??? Somehow, .*? is still greedy. + # regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*\.gnu\.lto_.*?\n(?=[[:space:]]*\.text\n)} $text {\1} text + regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text + } set match [regexp -- $pattern $text] if { $match == $positive } { @@ -108,6 +114,16 @@ proc scan-assembler { args } { set_required_options_for scan-assembler +proc scan-raw-assembler { args } { + set testcase [testname-for-summary] + # The name might include a list of options; extract the file name. + set filename [lindex $testcase 0] + set output_file "[file rootname [file tail $filename]].s" + dg-scan "scan-raw-assembler" 1 $testcase $output_file $args +} + +set_required_options_for scan-raw-assembler + # Check that a pattern is not present in the .s file produced by the # compiler. See dg-scan for details. @@ -487,6 +503,7 @@ proc scan-assembler-times { args } { set fd [open $output_file r] set text [read $fd] close $fd + regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text set result_count [llength [regexp -inline -all -- $pattern $text]] if {$result_count == $times} { @@ -548,6 +565,7 @@ proc scan-assembler-dem { args } { set output [remote_exec host "$cxxfilt" "" "$output_file"] set text [lindex $output 1] + regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text if [regexp -- $pattern $text] { pass "$testcase scan-assembler-dem $pp_pattern" @@ -604,6 +622,7 @@ proc scan-assembler-dem-not { args } { set output [remote_exec host "$cxxfilt" "" "$output_file"] set text [lindex $output 1] + regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text if ![regexp -- $pattern $text] { pass "$testcase scan-assembler-dem-not $pp_pattern" diff --git a/gcc/testsuite/gcc.dg/scantest-lto.c b/gcc/testsuite/gcc.dg/scantest-lto.c new file mode 100644 index 00000000000..5f8abaf77f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/scantest-lto.c @@ -0,0 +1,9 @@ +/* { dg-options "-O2 -flto" } */ + +void foo () +{ +} + +/* Check that scan-assembler* directives skip the LTO section. */ +/* { dg-final { scan-assembler-not "ascii" } } */ +/* { dg-final { scan-assembler-times "ascii" 0 } } */