[all-commits] [llvm/llvm-project] 4b11f9: [RISCV] Fix missing stack pointer recover

Kito Cheng via All-commits all-commits at lists.llvm.org
Thu Jun 9 08:39:06 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4b11f909030a9831e4dded93068f224bec0fe296
      https://github.com/llvm/llvm-project/commit/4b11f909030a9831e4dded93068f224bec0fe296
  Author: Kito Cheng <kito.cheng at sifive.com>
  Date:   2022-06-09 (Thu, 09 Jun 2022)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
    M llvm/test/CodeGen/RISCV/miss-sp-restore-eh.ll

  Log Message:
  -----------
  [RISCV] Fix missing stack pointer recover

In order to make sure the stack point is right through the EH region,
we also need to restore stack pointer from the frame pointer if we
don't preserve stack space within prologue/epilogue for outgoing variables,
normally it's just checking the variable sized object is present or not
is enough, but we also don't preserve that at prologue/epilogue when
have vector objects in stack.

Example to show what happened:
```
try {
  sp adjust for outgoing args. // 1. Sp changed.
  func_call  // 2. Exception raised
  sp restore // Oh, not restored
} catch {
  // 3. And now we are here.
}

// 4. Prepare to return!, restore return address from stack, but...sp is wrong.
// 5. Screw up!
```

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D126861




More information about the All-commits mailing list