[PATCH] D133860: StackProtector: enable tail call optimization even without musttail
Liqiang Tao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 18 16:42:31 PDT 2022
taolq added a comment.
In D133860#3796726 <https://reviews.llvm.org/D133860#3796726>, @efriedma wrote:
> Do we care that the backend might not choose to tail-call a function even if it's in tail position? The "tail" marker is a hint; depending on attributes, calling convention, etc., the backend might not actually generate a tail call.
I am not sure about this. Is that possible that a musttail-call is handled but a tail-call is not generated with all the same conditions?
================
Comment at: llvm/lib/CodeGen/StackProtector.cpp:485
Prev = Prev->getPrevNonDebugInstruction();
- if (Prev && isa<CallInst>(Prev) && cast<CallInst>(Prev)->isMustTailCall())
+ if (Prev && isa<CallInst>(Prev) && cast<CallInst>(Prev)->isTailCall())
CheckLoc = Prev;
----------------
efriedma wrote:
> Are you sure this actually does the right thing? Consider something like:
>
> ```
> tail call void f()
> call void g()
> ret void
> ```
>
> If I'm following correctly, we'll insert the guard before the call to f(), which seems wrong.
>
> (The old code worked because a musttail call is always in tail position; a "tail" call is not.)
Thanks for your comment. I didn't notice that.
So we should remove the latter if condition.
Or let the verifier guarantee a tail call is always in the tail position.
Which one could be better?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133860/new/
https://reviews.llvm.org/D133860
More information about the llvm-commits
mailing list