rmpowell77 / LIAW_2017_param

Library In A Week 2017 Parameter
MIT License
19 stars 5 forks source link

Unpack into make_map instead of using to_map #5

Closed ldionne closed 7 years ago

ldionne commented 7 years ago

This fixes the code generation issues. The problem is that to_map allows for duplicate keys in the "from" sequence, which means it needs to recursively insert into a hana::map. This is both very bad for codegen and for compile-times. make_map, on the other hand, requires all the keys to be distinct, which makes it much more straightforward and much easier to optimize.

With this, I get the following codegen for test_calls.cpp on Clang:

    .section    __TEXT,__text,regular,pure_instructions
    .macosx_version_min 10, 11
    .globl  __Z10call_kwfoov
    .p2align    4, 0x90
__Z10call_kwfoov:                       ## @_Z10call_kwfoov
    .cfi_startproc
## BB#0:
    pushq   %rbp
Lcfi0:
    .cfi_def_cfa_offset 16
Lcfi1:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
Lcfi2:
    .cfi_def_cfa_register %rbp
    movl    $2, %edi
    movl    $4, %esi
    movl    $3, %edx
    popq    %rbp
    jmp __Z3fooiii              ## TAILCALL
    .cfi_endproc

    .globl  __Z11call_kwfoo2v
    .p2align    4, 0x90
__Z11call_kwfoo2v:                      ## @_Z11call_kwfoo2v
    .cfi_startproc
## BB#0:
    pushq   %rbp
Lcfi3:
    .cfi_def_cfa_offset 16
Lcfi4:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
Lcfi5:
    .cfi_def_cfa_register %rbp
    movl    $2, %edi
    movl    $4, %esi
    movl    $3, %edx
    popq    %rbp
    jmp __Z3fooiii              ## TAILCALL
    .cfi_endproc

.subsections_via_symbols

Fixes #1

atomgalaxy commented 7 years ago

HA! I knew it would be some weird thing I wasn't thinking about :). Thanks!