[PATCH] D89239: [RISCV][PrologEpilogInserter] "Float" emergency spill slots to avoid making them immediately unreachable from the stack pointer

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 08:14:55 PST 2021


sebastian-ne added a comment.
Herald added a subscriber: vkmr.

Hi,
I’m not completely sure what is going on here, but I think this change is causing a bug.
I’m seeing multiple FIs pointing to the same memory (they have the same offset), the debug output looks like this (shortened):

  Reserved FI 24 for spilling FP
  alloc FI(33) at SP[0]
  …
  alloc FI(22) at SP[128]
  alloc FI(24) at SP[132]
  alloc FI(34) at SP[136]
  Adjusting emergency spill slots!
  Adjusting offset of emergency spill slot #34 from 136 to 132

In the end, the emergency spill slot overlaps with FI #24.

This happened on the amdgpu target (it’s not visible in the test change here). I think the problem occurs if the **stack grows upwards** (i.e. growing towards higher addresses; yeah, weird target). The code in `AdjustStackOffset` behaves differently in that case.

As a sidenote about the problem solved with this change:
In amdgpu, if we cannot scavenge a register to access a stack slot (i.e. because we currently want to spill one), we fallback to modifying the stack pointer:

  add sp, <offset>    ; <offset> is too large to be an immediate and we cannot scavenge a register
  load r1, sp         ; Access stack slot
  sub sp, <offset>    ; Restore original value


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89239/new/

https://reviews.llvm.org/D89239



More information about the llvm-commits mailing list