Bug 115673 - [15 regression] gcc.target/i386/force-indirect-call-2.c test failure
Summary: [15 regression] gcc.target/i386/force-indirect-call-2.c test failure
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: 15.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, ra, testsuite-fail
Depends on:
Blocks:
 
Reported: 2024-06-27 04:48 UTC by Sam James
Modified: 2024-07-22 22:19 UTC (History)
5 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-06-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2024-06-27 04:48:21 UTC
I had these differences when upgrading earlier (with a patched gcc for PR115661):
```
--- a/x86_64-pc-linux-gnu/15/x86_64-pc-linux-gnu.xfail
+++ b/x86_64-pc-linux-gnu/15/x86_64-pc-linux-gnu.xfail
@@ -438,6 +438,7 @@ FAIL: gcc.dg/nested-vla-1.c (test for excess errors)
 FAIL: gcc.dg/nested-vla-2.c (test for excess errors)
 FAIL: gcc.dg/nested-vla-3.c (test for excess errors)
 FAIL: gcc.dg/packed-vla.c (test for excess errors)
+FAIL: gcc.dg/pr10474.c scan-rtl-dump pro_and_epilogue "Performing shrink-wrapping"
 FAIL: gcc.dg/pr30473.c (test for excess errors)
 FAIL: gcc.dg/pr34457-1.c (test for excess errors)
 FAIL: gcc.dg/pr38902.c (test for excess errors)
@@ -794,6 +795,7 @@ Running gcc:/gcc/testsuite/gcc.target/i386/i386.exp ...
 FAIL: gcc.target/i386/cet-sjlj-3.c scan-assembler-times call\t_?longjmp 1
 FAIL: gcc.target/i386/cet-sjlj-5.c scan-assembler-times call\t_?longjmp 1
 FAIL: gcc.target/i386/fentryname3.c scan-assembler call\t\\*nop@GOTPCREL
+FAIL: gcc.target/i386/force-indirect-call-2.c scan-assembler-times (?:call|jmp)[ \\t]+\\*% 3
 FAIL: gcc.target/i386/pr101716.c scan-assembler leal[\\t ][^\\n]*eax
 FAIL: gcc.target/i386/pr101716.c scan-assembler-not movl[\\t ][^\\n]*eax
 FAIL: gcc.target/i386/pr101950-2.c scan-assembler-times \txor[ql]\t 2
@@ -802,6 +804,8 @@ UNRESOLVED: gcc.target/i386/pr113689-1.c compilation failed to produce executabl
 FAIL: gcc.target/i386/pr85044.c (test for excess errors)
 FAIL: gcc.target/i386/pr86722.c scan-assembler-not orpd
 FAIL: gcc.target/i386/pr86722.c scan-assembler-times (?n)(?:andnpd|andpd|blendvpd) 1
+FAIL: gcc.target/i386/pr91384.c scan-assembler-not testl
+FAIL: gcc.target/i386/stack-check-17.c scan-assembler-not pop
                === gfortran tests ===
```

Picking on force-indirect-call-2.c:
```
Executing on host: /tmp/build/gcc/xgcc -B/tmp/build/gcc/  /home/sam/git/gcc/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c    -fdiagnostics-plain-output  -O2 -mforce-indirect-call -fPIC -ffat-lto-objects -fno-ident -S -o force-indirect-call-2.s    (timeout = 300)
spawn -ignore SIGHUP /tmp/build/gcc/xgcc -B/tmp/build/gcc/ /home/sam/git/gcc/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c -fdiagnostics-plain-output -O2 -mforce-indirect-call -fPIC -ffat-lto-objects -fno-ident -S -o force-indirect-call-2
gcc.target/i386/force-indirect-call-2.c: (?:call|jmp)[ \\t]+\\*% found 1 times
FAIL: gcc.target/i386/force-indirect-call-2.c scan-assembler-times (?:call|jmp)[ \\t]+\\*% 3
```

I assume r15-1662-g629257bcb81434?
Comment 1 Sam James 2024-06-27 04:50:03 UTC
$ diff -u <(gcc-14 /home/sam/git/gcc/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c    -fdiagnostics-plain-output  -O2 -mforce-indirect-call -fPIC -ffat-lto-objects -fno-ident -S -o -) <(/tmp/build/gcc/xgcc -B/tmp/build/gcc/  /home/sam/git/gcc/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c    -fdiagnostics-plain-output  -O2 -mforce-indirect-call -fPIC -ffat-lto-objects -fno-ident -S -o -)
--- /dev/fd/63  2024-06-27 05:49:53.355792646 +0100
+++ /dev/fd/62  2024-06-27 05:49:53.357792668 +0100
@@ -29,17 +29,14 @@
 f2:
 .LFB2:
        .cfi_startproc
-       pushq   %rbx
+       subq    $8, %rsp
        .cfi_def_cfa_offset 16
-       .cfi_offset 3, -16
-       movq    f1@GOTPCREL(%rip), %rbx
-       call    *%rbx
+       call    *f1@GOTPCREL(%rip)
        leaq    f3(%rip), %rax
        call    *%rax
-       movq    %rbx, %rax
-       popq    %rbx
+       addq    $8, %rsp
        .cfi_def_cfa_offset 8
-       jmp     *%rax
+       jmp     *f1@GOTPCREL(%rip)
        .cfi_endproc
 .LFE2:
        .size   f2, .-f2
Comment 3 Richard Biener 2024-06-27 05:59:23 UTC
That's the bogus got alias set change.
Comment 4 Sam James 2024-06-27 06:02:26 UTC
FWIW, I hit it with a revert applied (not just the expand_move fix) to fix it, but I didn't test it very thoroughly. The CI report would've been without any revert.
Comment 5 Sam James 2024-06-28 15:23:21 UTC
Still fails with the GOT alias set fix on trunk.
Comment 6 Richard Biener 2024-06-30 09:53:01 UTC
So it likely expects f1@GOTPCREL(%rip) to be CSEd?

f2:
.LFB2:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        call    *f1@GOTPCREL(%rip)
        leaq    f3(%rip), %rax
        call    *%rax
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        jmp     *f1@GOTPCREL(%rip)

indeed with GCC 14 we get

f2:
.LFB2:
        .cfi_startproc
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        movq    f1@GOTPCREL(%rip), %rbx
        call    *%rbx
        leaq    f3(%rip), %rax
        call    *%rax
        movq    %rbx, %rax
        popq    %rbx
        .cfi_def_cfa_offset 8
        jmp     *%rax

I think both are perfectly OK for what the testcase should expect, so it's
a testism.  But I think it's also a missed optimization now.
Comment 7 Uroš Bizjak 2024-06-30 16:42:19 UTC
(In reply to Richard Biener from comment #6)
> So it likely expects f1@GOTPCREL(%rip) to be CSEd?
> 
> f2:
> .LFB2:
>         .cfi_startproc
>         subq    $8, %rsp
>         .cfi_def_cfa_offset 16
>         call    *f1@GOTPCREL(%rip)

This call is not indirect (through the register).

>         leaq    f3(%rip), %rax
>         call    *%rax
>         addq    $8, %rsp
>         .cfi_def_cfa_offset 8
>         jmp     *f1@GOTPCREL(%rip)

Neither is this sibcall indirect.

'-mforce-indirect-call'
     Force all calls to functions to be indirect.  This is useful when
     using Intel Processor Trace where it generates more precise timing
     information for function calls.