On line 37 I cast & call _intf__rtti_t27_issue81139__static__dispatchtest_d_Test_vmthelper0
which is a thunk method that calls
_intfstub_mi_t27_issue81139__static__dispatchtest_d_Test4_Test
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
given the parameters passed?
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.
In addition to the inlining problem you've noted, defining the thunk with too few arguments is likely to corrupt the remaining arguments.
I think you can avoid the issue with corrupted arguments by defining the thunk using a varargs type. But I don't think there's any existing solution for your inlining issue.
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.