https://bugs.llvm.org/show_bug.cgi?id=49686

            Bug ID: 49686
           Summary: PEI incorrectly moves emergency stack slot on targets
                    where the stack grows upwards
           Product: libraries
           Version: trunk
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Created attachment 24680
  --> https://bugs.llvm.org/attachment.cgi?id=24680&action=edit
Testcase that moves the spill slot offset to -8164

On systems, where the stack grows towards higher addresses (x86 and most others
grow towards lower addresses), the PrologEpilogInserter sometimes moves the
emergency spill slot to an offset, that is already occupied.
This behavior has been introduced in D89239, upwards growing stack were
probably an oversight.

Compiling the attached example leads to the following output:

$ llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs
-run-pass=prologepilog pei-scavenge-vgpr-spill.mir -debug
...
FP requires fallback spill to $vgpr2:0
alloc FI(0) at SP[0]
alloc FI(1) at SP[4]
alloc FI(3) at SP[8]
alloc FI(4) at SP[12]
Adjusting emergency spill slots!
Adjusting offset of emergency spill slot #4 from 12 to -8164

Where -8164 is the new offset (I guess that is a bit off the stack frame :)).


Another example, replacing the stack definitions in pei-scavenge-vgpr-spill.mir
with the following:
stack:
  - { id: 0, type: default, offset: 0, size: 8192, alignment: 64 }
  - { id: 1, type: default, offset: 0, size: 4, alignment: 4 }
  - { id: 2, type: default, offset: 0, size: 4, alignment: 4 }
  - { id: 3, type: default, offset: 0, size: 4, alignment: 4 }
  - { id: 4, type: default, offset: 0, size: 4, alignment: 4 }
  - { id: 5, type: default, offset: 0, size: 4, alignment: 4 }
  - { id: 6, type: default, offset: 0, size: 4, alignment: 4 }
  - { id: 7, type: default, offset: 0, size: 4, alignment: 4 }

leads to

$ llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs
-run-pass=prologepilog pei-scavenge-vgpr-spill.mir -debug
...
FP requires fallback spill to $vgpr2:0
alloc FI(0) at SP[0]
alloc FI(1) at SP[8192]
alloc FI(2) at SP[8196]
alloc FI(3) at SP[8200]
alloc FI(4) at SP[8204]
alloc FI(5) at SP[8208]
alloc FI(6) at SP[8212]
alloc FI(7) at SP[8216]
alloc FI(9) at SP[8220]
alloc FI(10) at SP[8224]
Adjusting emergency spill slots!
Adjusting offset of emergency spill slot #10 from 8224 to 8196

where the new offset of the emergency spill slot 8196 overlaps with FI(2).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to