This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Mark functions used in vtables as unnamed_addr.
ClosedPublic

Authored by pcc on Mar 10 2016, 4:50 PM.

Details

Summary

This marks virtual function declarations, as well as runtime library functions
cxa_pure_virtual, cxa_deleted_virtual and _purecall, as unnamed_addr. This
will allow us to correctly form relative references to them from vtables in
the relative vtable ABI.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 50377.Mar 10 2016, 4:50 PM
pcc retitled this revision from to CodeGen: Mark runtime functions with reserved names as unnamed_addr..
pcc updated this object.
pcc added reviewers: rsmith, rjmccall.
pcc added a subscriber: cfe-commits.
rjmccall edited edge metadata.Mar 10 2016, 10:25 PM

The underscore check seems over-broad; we support a lot of language dialects and runtimes besides the Itanium C++ runtime. This would be both more conservative and more convincing if it were constrained to the functions that we expect to put in v-tables.

pcc updated this revision to Diff 50500.Mar 11 2016, 4:41 PM
pcc edited edge metadata.

Restrict to functions referenced in virtual tables

pcc added subscribers: majnemer, rnk.Mar 11 2016, 4:41 PM

Done (this also affects _purecall in the MS ABI; I don't think this change should break anything there, but someone working on that might want to comment). Since this patch is now specific to virtual tables anyway, I've incorporated another relevant change, which is to mark virtual function declarations as unnamed_addr.

pcc retitled this revision from CodeGen: Mark runtime functions with reserved names as unnamed_addr. to CodeGen: Mark functions used in vtables as unnamed_addr..Mar 11 2016, 4:41 PM
pcc updated this object.

I see, they weren't being set on declarations, just definitions. Yes, this seems reasonable.

rnk accepted this revision.Mar 14 2016, 11:26 AM
rnk added a reviewer: rnk.
In D18071#373687, @pcc wrote:

Done (this also affects _purecall in the MS ABI; I don't think this change should break anything there, but someone working on that might want to comment). Since this patch is now specific to virtual tables anyway, I've incorporated another relevant change, which is to mark virtual function declarations as unnamed_addr.

That shouldn't matter. Virtual member functions are wrapped with a thunk, so comparisons won't actually involve pointers to __purecall.

This revision is now accepted and ready to land.Mar 14 2016, 11:26 AM
This revision was automatically updated to reflect the committed changes.

Member function comparisons of virtual functions aren't required to work anyway. Itanium just happens to implement them in a way that kindof gets it right (for simple cases).