[llvm] [RISCV][CFI] add function epilogue cfi information (PR #110810)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 07:47:03 PDT 2024


dlav-sc wrote:

> Nice update, I see the improvements!
> 
> I'm slightly confused as to why there sometimes is and sometimes is not any CFI information between a `cm.pop` and a `tail`/`ret`. I commented on one place where I saw this.

Thanks for taking a look at the tests!

I've changed the logic a bit and tried to make `cm.pop`, `cm.popret` and `cm.popretz` lowering right without an additional patch ([#110813](https://github.com/llvm/llvm-project/pull/110813)). However, I think that the solution with an additional patch is more robust than the current one. Now, I've added a check that:

- Verifies that the instruction after `cm.pop` is `PseudoRet`.
- If it is, CFI instructions after cm.pop is **not** omitted.

Another solution always emits CFI instructions after `cm.pop` and later, during `PushPopOptimize` pass, removes them if they aren't actually required. By the way, `PushPopOptimize` does the same things as my current solution: it finds `cm.pop` and checks that that the instruction after `cm.pop` appears to be `PseudoRet`. The only difference is that the `PushPopOptimize` pass is invoked later in the pipeline, almost before `ASMPrinter`.

However, if there is a guarantee that the epilogue isn't going to change after the CFI instructions emission, I expect that my current solution will stay correct.

Please let me know what you think of this matter.

https://github.com/llvm/llvm-project/pull/110810


More information about the llvm-commits mailing list