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

stack object should be 16-aligned but is not in the code #47

Open
matsc-at-sics-se opened this issue Jun 15, 2018 · 1 comment
Open
Labels
bug Something isn't working

Comments

@matsc-at-sics-se
Copy link
Owner

The LEA64r instruction is supposed to make a 16-aligned pointer, but does not.

---
name:            spti_jit_start_end_helper
fixedStack:      
  - { id: 0, offset: -8, size: 8, alignment: 8 }
stack:           
  - { id: 0, offset: -40, size: 24, alignment: 16 }
body:             |
  bb.0 (freq 3):
    successors: %bb.2(1), %bb.1(2)
  
    %rsp = SUB64ri32 %rsp, 40, implicit-def %eflags
    CMP32mi8 %rip, 1, _, @spti_hooked, _, 0, implicit-def %eflags
    JE_1 %bb.2, implicit %eflags
  
  bb.1 (freq 2):
    successors: %bb.2(1)
  
    MOV64mr %rip, 1, _, @spti + 24, _, %rcx
    %rax = LEA64r %rsp, 1, _, 8, _
    MOV64mr %rip, 1, _, @spti + 40, _, %rax
    MOV64mi32 %rip, 1, _, @spti + 32, _, 3
    MOV64mr %rsp, 1, _, 8, _, %rdi
    %edi = MOV32ri @spti
    %rax = MOVSX64rr32 %esi
    MOV64mr %rsp, 1, _, 16, _, %rax
    MOV64mr %rsp, 1, _, 24, _, %rdx
    %rsi = MOV64rm %rip, 1, _, @spti_cookie, _
    CALL64m %rip, 1, _, @spti_hook, _, implicit %rsp
    %xmm0 = VXORPSrr %xmm0, %xmm0
    VMOVUPSmr %rip, 1, _, @spti + 24, _, %xmm0
    MOV64mi32 %rip, 1, _, @spti + 40, _, 0
  
  bb.2 (freq 3):
  
    %rsp = ADD64ri32 %rsp, 40, implicit-def %eflags
    RETQ 42

...
@matsc-at-sics-se matsc-at-sics-se added the bug Something isn't working label Jun 15, 2018
@matsc-at-sics-se
Copy link
Owner Author

The bug is in Export/directFrame. It assigns an unaligned offset to an object that requires align = 16:

[...]
frame:
    %stack.0: offset = 16, size = 24, align = 16
[...]
Output from directFrame:
[...]
frame:
    %stack.0: offset = -40, size = 24, align = 16
[...]

Reproducer:
spti_jit_start_end_helper.uni.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant