https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118328

--- Comment #7 from Ken Jin <kenjin4096 at gmail dot com> ---
The files are too big to upload here, so I've uploaded them to
https://github.com/Fidget-Spinner/debugging-dump. They correspond to the main
interpreter loop of CPython
https://github.com/python/cpython/blob/e1988942ca26440a0df6f3949e93ddc0dbd1e57e/Python/ceval.c
.

Compiled with

/home/ken/GCC-15.0-trunk/bin/gcc -c -fno-strict-overflow -Wsign-compare
-DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter
-Wno-missing-field-initializers -Wstrict-prototypes
-Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal
-I./Include/internal/mimalloc  -I. -I./Include    -DPy_BUILD_CORE --save-temps
-o Python/ceval.o Python/ceval.c

Specifically, zoom in on the function _TAIL_CALL_YIELD_VALUE, it produces on
GCC 15 (note the assembly here might be slightly different than the one in .s
file, because it's from a different build but same flags passed):
        pushq   %rbx
        movq    -24(%rdi), %rax
        addq    $2, %rcx
        subl    $2, %r9d
        movq    -8(%rsi), %r8
        subq    $8, %rsi
        movb    %r9b, -5(%rdi)
        movq    %rcx, 56(%rdi)
        movq    %rsi, 64(%rdi)
        movq    %rax, 120(%rdx)
        movq    8(%rdi), %rax
        movq    $0, -24(%rdi)
        movq    56(%rax), %rcx
        movq    64(%rax), %rsi
        movq    %rax, 72(%rdx)
        addl    $1, 44(%rdx)
        movzwl  4(%rcx), %r9d
        movq    $0, 8(%rdi)
        addq    $4, %rcx
        addq    $8, %rsi
        movq    $0, 64(%rax)
        movl    %r9d, %ebx
        movzbl  %r9b, %edi
        movq    %r8, -8(%rsi)
        movzbl  %bh, %ebx
        movq    INSTRUCTION_TABLE(,%rdi,8), %r10
        movq    %rdi, %r8
        movq    %rax, %rdi
        movl    %ebx, %r9d
        popq    %rbx
        jmp     *%r10
        .string "ENTER_EXECUTOR is not supported in this build"

On Clang-19.1, it produces:

        movq    %r15, 56(%r12)
        movq    -8(%r13), %rcx
        addq    $-8, %r13
        addq    $2, %r15
        movq    %r15, 56(%r12)
        addb    $-2, %sil
        movb    %sil, -5(%r12)
        movq    %r13, 64(%r12)
        movq    -24(%r12), %rax
        movq    %rax, 120(%r14)
        movq    $0, -24(%r12)
        incl    44(%r14)
        movq    8(%r12), %rax
        movq    %rax, 72(%r14)
        movq    $0, 8(%r12)
        movq    56(%rax), %r15
        movq    64(%rax), %r13
        movq    $0, 64(%rax)
        movq    %rcx, (%r13)
        addq    $8, %r13
        movzwl  4(%r15), %esi
        addq    $4, %r15
        movzbl  %sil, %edi
        shrl    $8, %esi
        leaq    INSTRUCTION_TABLE(%rip), %rcx
        movq    %rax, %r12
        jmpq    *(%rcx,%rdi,8)

Reply via email to