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

Too many commas printed in address calculation ([rdi, +, 4*rdx]) #97

Open
LukasKalbertodt opened this issue Apr 11, 2019 · 2 comments
Open

Comments

@LukasKalbertodt
Copy link

Compiling this code:

pub fn foo(slice: &[u32], index: usize) -> u32 {
    slice[index]
}

Results in this output:

asm_test::foo:
 push    rax
 cmp     rdx, rsi
 jae     .LBB2_2
 mov     eax, dword, ptr, [rdi, +, 4*rdx]
 pop     rcx
 ret
.LBB2_2:
 mov     rax, rsi
 lea     rdi, [rip, +, .Lanon.be4e132a6194f90f951e33b03e0a9759.0]
 mov     rsi, rdx
 mov     rdx, rax
 call    qword, ptr, [rip, +, _ZN4core9panicking18panic_bounds_check17h3b44e6c3ebd56e36E@GOTPCREL]
 ud2

In particular mov eax, dword, ptr, [rdi, +, 4*rdx]. There are commas in the address calculations, but there shouldn't be any.

  • Expected: [rdi + 4*rdx]
  • Actual: [rdi, +, 4*rdx]

I think the main problem is in this code.

@gnzlbg
Copy link
Owner

gnzlbg commented Apr 11, 2019

Indeed, looks like we need to parse address calculations as its own AST node.

@malaire
Copy link

malaire commented Jun 2, 2021

Note also that commas in dword, ptr, should not be there.

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

3 participants