[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 4 11:21:55 PDT 2024
================
@@ -1185,6 +1190,21 @@ bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) {
TSK == TSK_ExplicitInstantiationDefinition)
return false;
+ // Itanium C++ ABI [5.2.3]:
+ // Virtual tables for dynamic classes are emitted as follows:
+ //
+ // - If the class is templated, the tables are emitted in every object that
+ // references any of them.
+ // - Otherwise, if the class is attached to a module, the tables are uniquely
+ // emitted in the object for the module unit in which it is defined.
+ // - Otherwise, if the class has a key function (see below), the tables are
+ // emitted in the object for the translation unit containing the definition of
+ // the key function. This is unique if the key function is not inline.
+ // - Otherwise, the tables are emitted in every object that references any of
+ // them.
+ if (RD->isInNamedModule())
+ return RD->shouldEmitInExternalSource();
----------------
dwblaikie wrote:
Shouldn't need to test "isInNamedModule" here, though? Would it be adequate to do:
```
if (RD->shouldEmitInExternalSource())
return true;
```
Ah, I geuss you want to return false ASAP too - I guess looking at some of the implementation details of `shouldEmitInExternalSource` and using those APIs directly here - Always -> true, Never -> false, I think?
Like `adjustGVALinkageForExternalDefinitionKind` already does? Or even reusing some of that functionality somehow.
https://github.com/llvm/llvm-project/pull/75912
More information about the cfe-commits
mailing list