https://gcc.gnu.org/g:b94331d9a3f7efb451bfad9db0fda162d3c46748

commit r15-4212-gb94331d9a3f7efb451bfad9db0fda162d3c46748
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Wed Oct 9 13:57:36 2024 +0100

    testsuite: Make check-function-bodies work with LTO
    
    This patch tries to make check-function-bodies automatically
    choose between reading the regular assembly file and reading the
    LTO assembly file.  There should only ever be one right answer,
    since check-function-bodies doesn't make sense on slim LTO output.
    
    Maybe this will turn out to be impossible to get right, but I'd like
    to try at least.
    
    gcc/testsuite/
            * lib/scanasm.exp (check-function-bodies): Look in ltrans0.ltrans.s
            if the test appears to be using LTO.

Diff:
---
 gcc/testsuite/lib/scanasm.exp | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
index 737eefc655e9..26504deb0e62 100644
--- a/gcc/testsuite/lib/scanasm.exp
+++ b/gcc/testsuite/lib/scanasm.exp
@@ -997,16 +997,17 @@ proc check-function-bodies { args } {
        error "too many arguments to check-function-bodies"
     }
 
+    upvar 2 dg-extra-tool-flags extra_tool_flags
+    set flags $extra_tool_flags
+
+    global torture_current_flags
+    if { [info exists torture_current_flags] } {
+       append flags " " $torture_current_flags
+    }
+
     if { [llength $args] >= 3 } {
        set required_flags [lindex $args 2]
 
-       upvar 2 dg-extra-tool-flags extra_tool_flags
-       set flags $extra_tool_flags
-
-       global torture_current_flags
-       if { [info exists torture_current_flags] } {
-           append flags " " $torture_current_flags
-       }
        foreach required_flag $required_flags {
            switch -- $required_flag {
                target -
@@ -1043,7 +1044,14 @@ proc check-function-bodies { args } {
 
     global srcdir
     set input_filename "$srcdir/$filename"
-    set output_filename "[file rootname [file tail $filename]].s"
+    set output_filename "[file rootname [file tail $filename]]"
+    if { [string match "* -flto *" " ${flags} "]
+        && ![string match "* -fno-use-linker-plugin *" " ${flags} "]
+        && ![string match "* -ffat-lto-objects *" " ${flags} "] } {
+       append output_filename ".ltrans0.ltrans.s"
+    } else {
+       append output_filename ".s"
+    }
 
     set prefix [lindex $args 0]
     set prefix_len [string length $prefix]

Reply via email to