What is swift_getGenericMetadata?

My advice in the attached thread would apply when you are trying to speed up generic code. Xcode’s Instruments labels specialized methods as such, so it is usually easy to tell how far down the call stack the compiler first failed to specialize something. Ultimately the compiler needs access to the implementation in order to specialize.

The undocumented @_specialize(...) will force specialization, but the compiler still needs to see enough to select the right specialized function, or else it has to sort out that selection at runtime. That causes it to have mixed results, because in some situations it can actually make things slower. I don’t recommend using it unless you really know what you are doing and you have no other choice.