llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

The stack slot position does not match the ABI.

Open 0x59616e opened this issue 3 years ago • 3 comments

In link-unlink.ll, the position of the local variables completely deviate from where they should be on the stack.

To name a few, take line 20 for example, this assembly is the counterpart of the IR on line 78, which should be at (-24, %a6).

0x59616e avatar Aug 08 '22 03:08 0x59616e

@llvm/issue-subscribers-backend-m68k

llvmbot avatar Aug 08 '22 03:08 llvmbot

Here is the simplified version:

define i32 @foo(i32 %a) {
entry:
  %ptr = alloca [2 x i32]
  %0 = getelementptr [2 x i32], ptr %ptr, i32 1
  store i32 %a, ptr %0
  ret i32 0
}
$ llc -mtriple=m68k-linux-gnu -o - test.ll -frame-pointer=all 
        .text
        .file   "test.ll"
        .globl  foo                             ; -- Begin function foo
        .p2align        1
        .type   foo,@function
foo:                                    ; @foo
        .cfi_startproc
; %bb.0:                                ; %entry
        link.w  %a6, #-8
        .cfi_def_cfa_offset -8
        .cfi_offset %a6, -8
        .cfi_def_cfa_register %a6
        move.l  (8,%a6), (0,%a6)
        move.l  #0, %d0
        unlk    %a6
        rts
.Lfunc_end0:
        .size   foo, .Lfunc_end0-foo
        .cfi_endproc
                                        ; -- End function
        .section        ".note.GNU-stack","",@progbits

move.l (8,%a6), (0,%a6) is incorrect, should be move.l (8,%a6), (-8,%a6) or move.l (8,%a6), (0,%sp)

0x59616e avatar Aug 17 '22 01:08 0x59616e

Candidate patch : D132007

0x59616e avatar Aug 17 '22 03:08 0x59616e

closed by 721a128bb36598967

0x59616e avatar Aug 27 '22 06:08 0x59616e