Skip to content

Try not to copy outgoing arguments #23657

@pcwalton

Description

@pcwalton

I see stuff like this in Servo's disassembly for arguments that are moved:

+0x1bcc             movq                -6256(%rbp), %rax
+0x1bd3             movq                %rax, -3344(%rbp)
+0x1bda             movaps              -6272(%rbp), %xmm0
+0x1be1             movaps              %xmm0, -3360(%rbp)
+0x1be8             movaps              -6288(%rbp), %xmm0
+0x1bef             movaps              %xmm0, -3376(%rbp)
+0x1bf6             movaps              -6304(%rbp), %xmm0
+0x1bfd             movaps              %xmm0, -3392(%rbp)
+0x1c04             movaps              -6368(%rbp), %xmm0
+0x1c0b             movaps              -6352(%rbp), %xmm1
+0x1c12             movaps              -6336(%rbp), %xmm2
+0x1c19             movaps              -6320(%rbp), %xmm3
+0x1c20             movaps              %xmm3, -3408(%rbp)
+0x1c27             movaps              %xmm2, -3424(%rbp)
+0x1c2e             movaps              %xmm1, -3440(%rbp)
+0x1c35             movaps              %xmm0, -3456(%rbp)
+0x1c3c             xorps               %xmm0, %xmm0
+0x1c3f             movaps              %xmm0, -6272(%rbp)
+0x1c46             movaps              %xmm0, -6288(%rbp)
+0x1c4d             movaps              %xmm0, -6304(%rbp)
+0x1c54             movaps              %xmm0, -6320(%rbp)
+0x1c5b             movaps              %xmm0, -6336(%rbp)
+0x1c62             movaps              %xmm0, -6352(%rbp)
+0x1c69             movaps              %xmm0, -6368(%rbp)
+0x1c70             movq                $0, -6256(%rbp)
+0x1c7b             leaq                -7600(%rbp), %rdi
+0x1c82             leaq                -3456(%rbp), %rsi
+0x1c89             callq               "vec_deque::VecDeque$LT$T$GT$::push_front::h12917901159388456219"

There's generally no need to copy by-move arguments. They should not be by-value at the LLVM level but should instead be by-pointer. Essentially codegen should opportunistically treat by-value as a hypothetical &own for aggregates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions