[clang] dbdd637 - Revert "[ABI] [C++20] [Modules] Don't generate vtable if the class is defined in other module unit"
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 16:18:45 PDT 2023
Author: Nico Weber
Date: 2023-06-14T16:17:42-07:00
New Revision: dbdd6372b7af2f6df5f41d19d966e6bac1b30208
URL: https://github.com/llvm/llvm-project/commit/dbdd6372b7af2f6df5f41d19d966e6bac1b30208
DIFF: https://github.com/llvm/llvm-project/commit/dbdd6372b7af2f6df5f41d19d966e6bac1b30208.diff
LOG: Revert "[ABI] [C++20] [Modules] Don't generate vtable if the class is defined in other module unit"
Breaks check-clang on win and mac, see comments on https://reviews.llvm.org/D150023
This reverts commit d8a36b00d198fdc2ea866ea5da449628db07070f.
Also revert follow-up "[NFC] skip the test modules-vtable.cppm on windows"
This reverts commit baf0b12ca6c624b2a59aa6f2fd0310c72d35ac56.
Added:
Modified:
clang/lib/CodeGen/CGVTables.cpp
Removed:
clang/test/CodeGenCXX/modules-vtable.cppm
################################################################################
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index fb0276af57b25..32259d1e4cbff 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -1172,16 +1172,9 @@ bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) {
if (!keyFunction)
return false;
- const FunctionDecl *Def;
// Otherwise, if we don't have a definition of the key function, the
// vtable must be defined somewhere else.
- if (!keyFunction->hasBody(Def))
- return true;
-
- assert(Def && "The body of the key function is not assigned to Def?");
- // If the non-inline key function comes from another module unit, the vtable
- // must be defined there.
- return Def->isInAnotherModuleUnit() && !Def->isInlineSpecified();
+ return !keyFunction->hasBody();
}
/// Given that we're currently at the end of the translation unit, and
diff --git a/clang/test/CodeGenCXX/modules-vtable.cppm b/clang/test/CodeGenCXX/modules-vtable.cppm
deleted file mode 100644
index 5662f40515cd6..0000000000000
--- a/clang/test/CodeGenCXX/modules-vtable.cppm
+++ /dev/null
@@ -1,98 +0,0 @@
-// REQUIRES: !system-windows
-
-// RUN: rm -rf %t
-// RUN: split-file %s %t
-// RUN: cd %t
-//
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -emit-module-interface \
-// RUN: %t/Mod.cppm -o %t/Mod.pcm
-//
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/Mod.pcm \
-// RUN: -emit-llvm -o - | FileCheck %t/Mod.cppm
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -fmodule-file=Mod=%t/Mod.pcm \
-// RUN: %t/Use.cpp -emit-llvm -o - | FileCheck %t/Use.cpp
-//
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -emit-module-interface \
-// RUN: %t/Mod.cppm -o %t/Mod.pcm -DKEY_FUNCTION_INLINE
-//
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/Mod.pcm \
-// RUN: -emit-llvm -o - | FileCheck %t/Mod.cppm -check-prefix=CHECK-INLINE
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -fmodule-file=Mod=%t/Mod.pcm \
-// RUN: %t/Use.cpp -emit-llvm -o - | FileCheck %t/Use.cpp -check-prefix=CHECK-INLINE
-//
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -emit-module-interface \
-// RUN: %t/M-A.cppm -o %t/M-A.pcm
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -fmodule-file=M:A=%t/M-A.pcm \
-// RUN: %t/M-B.cppm -emit-llvm -o - | FileCheck %t/M-B.cppm
-
-//--- Mod.cppm
-export module Mod;
-
-export class Base {
-public:
- virtual ~Base();
-};
-#ifdef KEY_FUNCTION_INLINE
-inline
-#endif
-Base::~Base() {}
-
-// CHECK: @_ZTVW3Mod4Base = unnamed_addr constant
-// CHECK: @_ZTSW3Mod4Base = constant
-// CHECK: @_ZTIW3Mod4Base = constant
-
-// CHECK-INLINE: @_ZTVW3Mod4Base = linkonce_odr unnamed_addr constant
-// CHECK-INLINE: @_ZTSW3Mod4Base = linkonce_odr constant
-// CHECK-INLINE: @_ZTIW3Mod4Base = linkonce_odr constant
-
-module :private;
-int private_use() {
- Base base;
- return 43;
-}
-
-//--- Use.cpp
-import Mod;
-int use() {
- Base* base = new Base();
- return 43;
-}
-
-// CHECK-NOT: @_ZTSW3Mod4Base = constant
-// CHECK-NOT: @_ZTIW3Mod4Base = constant
-// CHECK: @_ZTVW3Mod4Base = external unnamed_addr
-
-// CHECK-INLINE: @_ZTVW3Mod4Base = linkonce_odr unnamed_addr constant
-// CHECK-INLINE: @_ZTSW3Mod4Base = linkonce_odr constant
-// CHECK-INLINE: @_ZTIW3Mod4Base = linkonce_odr constant
-
-// Check the case that the declaration of the key function comes from another
-// module unit but the definition of the key function comes from the current
-// mdoule unit.
-
-//--- M-A.cppm
-export module M:A;
-export class C {
-public:
- virtual ~C();
-};
-
-int a_use() {
- C c;
- return 43;
-}
-
-//--- M-B.cppm
-export module M:B;
-import :A;
-
-C::~C() {}
-
-int b_use() {
- C c;
- return 43;
-}
-
-// CHECK: @_ZTVW1M1C = unnamed_addr constant
-// CHECK: @_ZTSW1M1C = constant
-// CHECK: @_ZTIW1M1C = constant
More information about the cfe-commits
mailing list