forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit
of dynamic classes Close llvm#70585 and reflect itanium-cxx-abi/cxx-abi#170. The significant change of the patch is: for dynamic classes attached to module units, we generate the vtable to the attached module units directly and the key functions for such classes is meaningless.
- Loading branch information
1 parent
7a3b0cb
commit 7a5c4cc
Showing
9 changed files
with
139 additions
and
26 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
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,47 @@ | ||
// REQUIRES: !system-windows | ||
|
||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
// RUN: cd %t | ||
// | ||
// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \ | ||
// RUN: -emit-module-interface -o %t/foo-layer1.pcm | ||
// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple \ | ||
// RUN: -emit-module-interface -fmodule-file=foo:layer1=%t/foo-layer1.pcm \ | ||
// RUN: -o %t/foo-layer2.pcm | ||
// RUN: %clang_cc1 -std=c++20 %t/foo-layer1.pcm -S -emit-llvm -o - | FileCheck %t/layer1.cppm | ||
// RUN: %clang_cc1 -std=c++20 %t/foo-layer2.pcm -S -emit-llvm -o - \ | ||
// RUN: -fmodule-file=foo:layer1=%t/foo-layer1.pcm | FileCheck %t/layer2.cppm | ||
// | ||
// Check the case about emitting object files from sources directly. | ||
// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \ | ||
// RUN: -S -emit-llvm -o - | FileCheck %t/layer1.cppm | ||
// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple -S -emit-llvm \ | ||
// RUN: -fmodule-file=foo:layer1=%t/foo-layer1.pcm -o - | FileCheck %t/layer2.cppm | ||
|
||
//--- layer1.cppm | ||
export module foo:layer1; | ||
struct Fruit { | ||
virtual ~Fruit() = default; | ||
virtual void eval(); | ||
}; | ||
|
||
// CHECK-DAG: @_ZTVW3foo5Fruit = unnamed_addr constant | ||
// CHECK-DAG: @_ZTSW3foo5Fruit = constant | ||
// CHECK-DAG: @_ZTIW3foo5Fruit = constant | ||
|
||
// Testing that: | ||
// (1) The use of virtual functions won't produce the vtable. | ||
// (2) The definition of key functions won't produce the vtable. | ||
// | ||
//--- layer2.cppm | ||
export module foo:layer2; | ||
import :layer1; | ||
export void layer2_fun() { | ||
Fruit *b = new Fruit(); | ||
b->eval(); | ||
} | ||
void Fruit::eval() {} | ||
// CHECK: @_ZTVW3foo5Fruit = external unnamed_addr constant | ||
// CHECK-NOT: @_ZTSW3foo5Fruit | ||
// CHECK-NOT: @_ZTIW3foo5Fruit |