[RISCV] Pre-commit testcase for PR55442
authorKito Cheng <kito.cheng@sifive.com>
Thu, 9 Jun 2022 15:34:13 +0000 (23:34 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 9 Jun 2022 15:35:38 +0000 (23:35 +0800)
commit8b3426569e1fe3105ad57b635689b4b94936b111
treecee97f747521a2147ce61a00a197e19ce54e4c74
parent56e19717f56ac7b96d1eb91107fe666429363ef7
[RISCV] Pre-commit testcase for PR55442

The testcase show the stack pointer isn't recovered when we got
exception from `_Z3fooiiiiiiiiiiPi`, and then we screw up due to
restore return address from wrong stack pointer.

NOTE:
Trigger conditions:
1. Frame pointer is required.
2. Stack has out-going argument
3. Vector extension is enabled.

Another run-able testcase:

$ clang++ -target riscv64-unknown-linux-gnu -march=rv64gcv test.cpp
```
void __attribute__((noinline)) foo(int, int, int, int, int, int, int, int, int, int, int *){
 throw int(0);
}

int main(int argc, char **argv) {
  int exception_value = 1;
  try {
      foo(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  } catch (int i) {
    exception_value = i;
  }
  return exception_value;
}
```

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D126860
llvm/test/CodeGen/RISCV/miss-sp-restore-eh.ll [new file with mode: 0644]