[LLVMdev] Proposal: Add a guaranteed tail call marker

Reid Kleckner rnk at google.com
Tue Apr 1 11:20:58 PDT 2014


On Tue, Apr 1, 2014 at 11:03 AM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> Having this also puts us on the path to improve itanium codegen for
>
> struct A {
>   virtual void f(int x, ...);
> };
> struct B {
>   virtual void f(int x, ...);
> };
> struct C : A, B {
>   virtual void c();
>   virtual void f(int x, ...);
> };
> void C::f(int x, ...) {  }
>
> Currently we have clang duplicate the body of C::f.  We cannot create
> a normal copy since we cannot represent the copy of the varargs, even
> when we want llvm to eliminate those copies. We could use a inalloca
> argument for the rest of the frame instead of a "...". Since we have a
> guarantee that no copy will be done, we don't have to know the size.
>

Yep!  Fixing this problem is definitely doable with this feature.  Rather
than using inalloca, I'd add an Ellipsis Value so we can write:
musttail call void @fn(i8* %this_adj, ...)

You wouldn't be able to place '...' anywhere other than as the last
argument of a musttail call, since we can't really lower it otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140401/f8f9c658/attachment.html>


More information about the llvm-dev mailing list