================ @@ -6853,6 +6853,13 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never) DI->completeUnusedClass(*CRD); } + // If we're emitting a dynamic class from the importable module we're + // emitting, we always need to emit the virtual table according to the ABI + // requirement. + if (CRD->getDefinition() && CRD->isDynamicClass() && + CRD->isInCurrentModuleUnit()) + EmitVTable(CRD); ---------------- ChuanqiXu9 wrote:
`Sema::DefineUsedVTables` is executed in all cases. However, in two phase compilation, the consumer in the first phase is not the CodeGenConsumer but the ASTWriter, so when the code get executed: https://github.com/llvm/llvm-project/blob/876c6204f12fa2738ff8ca886e664b826847d6d4/clang/lib/Sema/SemaDeclCXX.cpp#L18758-L18759 the corresponding `HandleVTable` in CodeGen Consumer won't get executed. In the second phase, the CodeGen consumer will be the consumer, and the AST Reader will pass the interesting decls to the consumer: https://github.com/llvm/llvm-project/blob/e9a362362e03c6aea7a64473e8b8bb9140fd3855/clang/lib/Serialization/ASTReader.cpp#L8052-L8057 https://github.com/llvm/llvm-project/pull/75912 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits