[PATCH] D52238: [CodeGen] Enable tail calls for functions with NonNull attributes.
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 24 07:21:12 PDT 2018
dmgreen added inline comments.
================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:63
.removeAttribute(Attribute::NoAlias)
+ .removeAttribute(Attribute::NonNull)
.hasAttributes())
----------------
efriedma wrote:
> dmgreen wrote:
> > efriedma wrote:
> > > Test coverage for this change? (This codepath is primarily used by SelectionDAGLegalize::ExpandLibCall, so probably unlikely to be relevant in practice, but it should be possible to construct a synthetic testcase.)
> > My understanding is that we need an intrinsic that returns a ptr and is lowered to a call. Any idea what that might be? I had a look round and couldn't find anything, and an assert that RetTy isn't a pointer type didn't throw up anything in the test suite.
> You don't actually need an intrinsic that returns pointer; you can just take an intrinsic that returns an int and use inttoptr on the result.
The check in ExpandLibcall seems to be:
bool isTailCall =
TLI.isInTailCallPosition(DAG, Node, TCChain) &&
(RetTy == F.getReturnType() || F.getReturnType()->isVoidTy());
If I comment out that return type check, it does seem to tail call something like __clzsi2 as expected (and nonnull used to disable this, no longer does). But as-is, doesn't seem to like tail calling if the types don't match up.
https://reviews.llvm.org/D52238
More information about the llvm-commits
mailing list