[PATCH] D111519: [WIP] [RISCV] Emit cfi directives for function epilogue

Shivam Gupta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 14 20:49:09 PST 2021


xgupta added a comment.

I have teken this exmaple from https://reviews.llvm.org/D69723 to understand the problem with stack unwinding.

cat test.cpp

  void three() {
      throw 7;
  }
  
  void two(void) {
      try {
          three();
      } catch(int &c) {
          throw 42;
      }
  }
  
  int main() {
      try {
          two();
      }
      catch(...) {
      }
      return 0;
  }

If I see the output of the generated assembly in both GCC RISCV and Clang RISCV cases, differences can be seen in three directive lines sequence in epilogue. 
clang RISCV epilogue:

  .cfi_def_cfa sp, 48
   ld      ra, 40(sp)            
  .cfi_restore ra
  .cfi_restore s0

vs

GCC RISCV epilogue where 1= ra and 8= s0:

  .cfi_restore 1
  ld      s0,0(sp)
  .cfi_restore 8
  .cfi_def_cfa 2, 16

So I will assume these three lines need to be corrected to match GCC and fix the issue.

F20363643: clang-vs-gcc_riscv.png <https://reviews.llvm.org/F20363643>


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111519



More information about the llvm-commits mailing list