The provided test shows a case where enabling coverage instrumentation causes a link error during building. Normally the all the base class items (vtable, ctors and dtors) would be removed in an optimized build. But when building with coverage instrumentation the ctors and dtors are always issued and access the vtable. However, the vtable remains with external linkage. As nobody ever instantiates the base class the vtable remains undefined and causes a link error.
This patch changes the behavior when deciding the vtable linkage when generating coverage instrumentation. vtables are always generated as local linkonce objects.
This is slightly wasteful of link time and target storage but the profile instrumentation is performed too early (as far as I can see) to not instrument ctors/dtors that will later be discarded.