<div dir="ltr">If you add varargs to the thunk prototype and to the musttail call inside of it, the inliner should be able to inline through it. Check out the LLVM tests at llvm/test/Transforms/Inline/inline-varargs.ll for examples of what currently works.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 4, 2018 at 12:11 PM Carlo Kok <<a href="mailto:ck@remobjects.com">ck@remobjects.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On Thu, Oct 4, 2018, at 20:53, Friedman, Eli wrote:<br>
> On 10/4/2018 11:14 AM, Carlo Kok wrote:<br>
> ><br>
> > On Thu, Oct 4, 2018, at 20:05, Friedman, Eli wrote:<br>
> >> On 10/4/2018 1:58 AM, Carlo Kok via llvm-dev wrote:<br>
> >>> Hi,<br>
> >>><br>
> >>> is there a way I can tell llvm to optimize through a call to a thunk method?<br>
> >>><br>
> >>> <a href="https://gist.github.com/carlokok/3ba9cb1a36a145a3071a7b901867d442" rel="noreferrer" target="_blank">https://gist.github.com/carlokok/3ba9cb1a36a145a3071a7b901867d442</a><br>
> >>><br>
> >>> On line 37 I cast & call _intf__rtti_t27_issue81139__static__dispatchtest_d_Test_vmthelper0<br>
> >>><br>
> >>> which is a thunk method that calls<br>
> >>> _intfstub_mi_t27_issue81139__static__dispatchtest_d_Test4_Test<br>
> >>><br>
> >>> Is there a way to tell the optimizer to get rid of the thunk call? Since llvm can prove it will end up in _intfstub_mi_t27_issue81139__static__dispatchtest_d_Test4_Test<br>
> >>> given the parameters passed?<br>
> >> LLVM is conservative if the callee of a call is bitcast in a non-trivial<br>
> >> way; it treats the call as opaque.<br>
> >><br>
> >> What are you trying to accomplish by passing the wrong number of<br>
> >> arguments to the call?<br>
> >><br>
> > The vmt helper does a tail call that acts like a thunk. The final method has the right number of parameters and I adjust the sig to match the calling convention. It's essentially a trick to do interface dispatch without requiring an explicit vmt per interface.<br>
> <br>
> In addition to the inlining problem you've noted, defining the thunk <br>
> with too few arguments is likely to corrupt the remaining arguments.<br>
> <br>
> I think you can avoid the issue with corrupted arguments by defining the <br>
> thunk using a varargs type.  But I don't think there's any existing <br>
> solution for your inlining issue.<br>
><br>
<br>
Thnx. I'm not getting corruption so I'm good there. Was hoping for a solution to the in lining but that can't be helped.<br>
</blockquote></div>