[PATCH] D71509: [ELF][PPC64] Implement IPLT code sequence for non-preemptible IFUNC

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 10:26:15 PST 2019


sfertile added a comment.

I'm not super knowledgeable on IFuncs so I really appreciate the detailed descriptions you've provided. I'll start brushing up on ifuncs so I can review  this. I have one early observation though: If its valid to tail call a non-preemptible ifunc (and since its non-preemptible I'm assuming it is tail-callable) , then saving of the toc pointer in the stub is not safe.

Take for example:  a function `A` that calls `B` that tail calls `C`; where `C` is a non-preemptable ifunc, and `A` and `B` are either in different linkage modules or `B`is preemptable.

`A` --> `Plt stub` --> `B` --> `IPltstub` --> `C`

The plt stub between `A` and `B` saves the toc-pointer from `A`'s module to the linkage area. When `B` tail calls `C`  it has poped off the stack frame its allocated (if it had one), the IPlt stub will overwrite the toc-pointer from `A`'s module with the toc-pointer shared by `B` and `C`. When we return to the call site in `A` we will restore the wrong toc-pointer. Since the IFunc is non-preemptable and LLD doesn't support multiple TOC bases in a module (I belive bfd has an option for this when using small code model but I am not sure) I would think the caller and callee have to share the same TOC pointer, so no toc save is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71509





More information about the llvm-commits mailing list