Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem about compiling the humanEval testset #39

Open
wang-yongpan opened this issue Dec 24, 2024 · 2 comments
Open

Problem about compiling the humanEval testset #39

wang-yongpan opened this issue Dec 24, 2024 · 2 comments

Comments

@wang-yongpan
Copy link

hi,

I would like to know how the assembly code in the decompile-eval-executable-gcc-obj.json data you released was compiled. I found that your assembly code is different from mine. For example,

char *func0(const char *a, const char *b) {
    int len_a = strlen(a);
    int len_b = strlen(b);
    int min_len = len_a < len_b ? len_a : len_b;
    char *output = malloc((min_len + 1) * sizeof(char));
    if (!output) return NULL;

    for (int i = 0; i < min_len; i++) {
        output[i] = (a[i] == b[i]) ? '0' : '1';
    }
    output[min_len] = '\0';
    return output;
}

Your assembly code:

<func0>:
...
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
...

compile ins:

gcc -o 1.o 1.c -O1 -shared -fPIC -lm

My results:

...
mov    $0xffffffffffffffff,%rbx
mov    $0x0,%eax
mov    %rbx,%rcx
repnz scas %es:(%rdi),%al
not    %rcx
lea    (%rcx,%rbx,1),%rdx
mov    %rbx,%rcx
mov    %rsi,%rdi
repnz scas %es:(%rdi),%al
...

Obviously, the strlen function is optimized to the repnz instruction, but your result is not optimized.

Thankx!

@wang-yongpan
Copy link
Author

And I found that if i use option -fno-builtin, i can get your results. Did you use this to get the results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@wang-yongpan and others