[PATCH] D158190: [wip] AMDGPU: Try to restore SP correctly in presence of dynamic stack adjustments

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 01:42:58 PDT 2023


sebastian-ne added a comment.

> The problem is if there were any dynamic stack adjustments, the restore using a fixed offset just assumed none happened.

I see, that is problematic.

An example, where I think the new code fails:

  sp = 0x10
  alignment = 0x20
  frameSize = 0x10
  
  // prologue
  fp = sp + (alignment - 1) = 0x2f
  fp &= -alignment = 0x20
  sp += frameSize + alignment = 0x40
  // some dynamic allocation happens
  sp += 0x18 = 0x58
  // everything ok so far
  
  // epilogue
  sp = fp - (alignment - 1) = 0x20 - 0x1f = 0x01
  // but sp was 0x10 at the start


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

https://reviews.llvm.org/D158190



More information about the llvm-commits mailing list