This is an archive of the discontinued LLVM Phabricator instance.

[WPD] Emit vcall_visibility metadata for MicrosoftCXXABI
ClosedPublic

Authored by tejohnson on Jan 25 2020, 7:45 AM.

Details

Summary

The MicrosoftCXXABI uses a separate mechanism for emitting vtable
type metadata, and thus didn't pick up the change from D71907
to emit the vcall_visibility metadata under -fwhole-program-vtables.

I believe this is the cause of a Windows bot failure when I committed
follow on change D71913 that required a revert. The failure occurred
in a CFI test that was expecting to not abort because it expected a
devirtualization to occur, and without the necessary vcall_visibility
metadata we would not get devirtualization.

Note in the equivalent code in CodeGenModule::EmitVTableTypeMetadata
(used by the ItaniumCXXABI), we also emit the vcall_visibility metadata
when Virtual Function Elimination is enabled. Since I am not as familiar
with the details of that optimization, I have marked that as a TODO and
am only inserting under -fwhole-program-vtables.

Event Timeline

tejohnson created this revision.Jan 25 2020, 7:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2020, 7:45 AM
Herald added a subscriber: Prazek. · View Herald Transcript

I fixed the test matching as I found that the names generated for the anonymous namespace comdats depend on the module identifier in some way. I changed the matching to look at the struct type embedded in the initializer, which is also more intuitive. I also moved the new MS checks to be alongside the companion Itanium checks. And I added comments noting that MSVC gets DSO (hidden) visibility by default.

tejohnson updated this revision to Diff 240395.Jan 25 2020, 1:30 PM

Improve test

This revision is now accepted and ready to land.Jan 27 2020, 1:32 AM
This revision was automatically updated to reflect the committed changes.

@tejohnson I was wondering where does this @anon.{{.*}} gets set, or in general where can I find more information about it.

When I step through the code in emitVTableTypeMetadata, it's still.

@0 = private unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4A@?A0x3E47408C@@6B@" to i8*), i8* bitcast (i32 (%"struct.(anonymous namespace)::A"*)* @"?f@A@?A0x3E47408C@@UEAAHXZ" to i8*)] }, comdat($"??_7A@?A0x3E47408C@@6B@")

Thanks

@tejohnson I was wondering where does this @anon.{{.*}} gets set, or in general where can I find more information about it.

When I step through the code in emitVTableTypeMetadata, it's still.

@0 = private unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4A@?A0x3E47408C@@6B@" to i8*), i8* bitcast (i32 (%"struct.(anonymous namespace)::A"*)* @"?f@A@?A0x3E47408C@@UEAAHXZ" to i8*)] }, comdat($"??_7A@?A0x3E47408C@@6B@")

Thanks

It would be later, in LLVM, see nameUnamedGlobals in llvm/lib/Transforms/Utils/NameAnonGlobals.cpp. It is called towards the end the compile when generating bitcode for LTO, as we need everything named in order to generate summary information.