mirrored from git://gcc.gnu.org/git/gcc.git
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
c++: Implement modules ABI for vtable emissions
This patch implements the changes described in itanium-cxx-abi/cxx-abi#171. One restriction that is lifted in the ABI that hasn't been updated here is that the ABI no longer requires unique vtables to be emitted with vague linkage. I haven't changed this behaviour for this patch, but in the future we could look into changing the relevant target hook ('class_data_always_comdat') to default to 'false'. But the current behaviour is more forgiving to changes in key function identification. Since the ABI for vtables attached to named modules no longer depends on key methods, this also resolves the issue described in PR c++/105224. PR c++/105224 gcc/cp/ChangeLog: * class.cc (finish_struct_1): Also push classes attached to a module into the 'keyed_classes' list. * decl.cc (record_key_method_defined): Don't push classes attached to a named module into the 'keyed_classes' list. * module.cc (trees_in::read_class_def): Likewise. * decl2.cc (import_export_class): Uniquely emit vtables for non-template classes attached to a named module. (vtables_uniquely_emitted): New function. (import_export_decl): Update comments. Update with knowledge about new kinds of uniquely emitted vtables. gcc/testsuite/ChangeLog: * g++.dg/modules/virt-2_a.C: Update linkage requirements. * g++.dg/modules/virt-2_b.C: Likewise. * g++.dg/modules/virt-2_c.C: Likewise. * g++.dg/modules/virt-4_a.C: New test. * g++.dg/modules/virt-4_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
- Loading branch information
Showing
9 changed files
with
151 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// { dg-additional-options "-fmodules-ts" } | ||
// Test changes for https://github.com/itanium-cxx-abi/cxx-abi/pull/171 | ||
|
||
export module M; | ||
|
||
// Attached to module, should only be emitted in this TU | ||
// { dg-final { scan-assembler {_ZTVW1M8Attached:} } } | ||
// { dg-final { scan-assembler {_ZTIW1M8Attached:} } } | ||
// { dg-final { scan-assembler {_ZTSW1M8Attached:} } } | ||
export struct Attached { | ||
virtual void key(); | ||
}; | ||
|
||
// Not attached to module, should be emitted where key function is | ||
// { dg-final { scan-assembler-not {_ZTV10Unattached:} } } | ||
// { dg-final { scan-assembler-not {_ZTI10Unattached:} } } | ||
// { dg-final { scan-assembler-not {_ZTS10Unattached:} } } | ||
export extern "C++" struct Unattached { | ||
// Key function not defined here | ||
virtual void key(); | ||
}; | ||
|
||
// Template, should be emitted everywhere it's used | ||
export template <typename T> struct Templated { | ||
virtual void key() {} | ||
}; | ||
|
||
// { dg-final { scan-assembler {_ZTVW1M9TemplatedIiE:} } } | ||
// { dg-final { scan-assembler {_ZTIW1M9TemplatedIiE:} } } | ||
// { dg-final { scan-assembler {_ZTSW1M9TemplatedIiE:} } } | ||
static Templated<int> x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// { dg-additional-options "-fmodules-ts" } | ||
|
||
module M; | ||
|
||
// Attached to module, shouldn't be defined in this TU | ||
// (was already emitted in interface unit) | ||
// { dg-final { scan-assembler-not {_ZTVW1M8Attached:} } } | ||
// { dg-final { scan-assembler-not {_ZTIW1M8Attached:} } } | ||
// { dg-final { scan-assembler-not {_ZTSW1M8Attached:} } } | ||
void Attached::key() {} | ||
|
||
// Not attached to module and this is the key function, | ||
// so vtables and RTTI should be emitted here | ||
// { dg-final { scan-assembler {_ZTV10Unattached:} } } | ||
// { dg-final { scan-assembler {_ZTI10Unattached:} } } | ||
// { dg-final { scan-assembler {_ZTS10Unattached:} } } | ||
extern "C++" void Unattached::key() {} | ||
|
||
// Template vtables should be emitted wherever it's used | ||
// { dg-final { scan-assembler {_ZTVW1M9TemplatedIiE:} } } | ||
// { dg-final { scan-assembler {_ZTIW1M9TemplatedIiE:} } } | ||
// { dg-final { scan-assembler {_ZTSW1M9TemplatedIiE:} } } | ||
static Templated<int> y; |