diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
index 897ce76eae5..9291735386a 100644
--- a/gcc/testsuite/lib/scanasm.exp
+++ b/gcc/testsuite/lib/scanasm.exp
@@ -1219,10 +1219,16 @@ proc check-function-bodies { args } {
     global srcdir
     set input_filename "$srcdir/$filename"
     set output_filename "[file rootname [file tail $filename]]"
+    # With slim LTO the regular .s holds no assembly, so a link test reads
+    # the post-LTO LTRANS output instead.  A compile-only test produces no
+    # LTRANS file; check-function-bodies' required-options force
+    # -ffat-lto-objects for it, so fall back to the (now non-empty) .s.
+    set lto_filename "$output_filename.ltrans0.ltrans.s"
     if { [string match "* -flto *" " ${flags} "]
 	 && ![string match "* -fno-use-linker-plugin *" " ${flags} "]
-	 && ![string match "* -ffat-lto-objects *" " ${flags} "] } {
-	append output_filename ".ltrans0.ltrans.s"
+	 && ![string match "* -ffat-lto-objects *" " ${flags} "]
+	 && [file exists $lto_filename] } {
+	set output_filename $lto_filename
     } else {
 	append output_filename ".s"
     }
@@ -1321,3 +1327,5 @@ proc check-function-bodies { args } {
 	error "check-function-bodies: no matches found"
     }
 }
+
+set_required_options_for check-function-bodies
