diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-07-06 00:30:00 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-07-06 00:30:00 +0000 |
commit | b51cf1136fe231b45dc45713086d182b3a75e773 (patch) | |
tree | 7fa6f38d56006cf3051b6a0330aa01f8a9f8e881 /clang/test | |
parent | 29c5f16ad028238d743f958b8205c53fad3d2e1d (diff) | |
download | bcm5719-llvm-b51cf1136fe231b45dc45713086d182b3a75e773.tar.gz bcm5719-llvm-b51cf1136fe231b45dc45713086d182b3a75e773.zip |
[modules ts] Do not emit strong function definitions from the module interface unit in every user.
llvm-svn: 307232
Diffstat (limited to 'clang/test')
3 files changed, 90 insertions, 0 deletions
diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp new file mode 100644 index 00000000000..c8b8725ed2a --- /dev/null +++ b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t +// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module + +module Module; + +void use() { + // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv + used_inline_exported(); + // CHECK: declare {{.*}}@_Z18noninline_exportedv + noninline_exported(); + + // FIXME: This symbol should not be visible here. + // CHECK: define internal {{.*}}@_ZL26used_static_module_linkagev + used_static_module_linkage(); + + // FIXME: The module name should be mangled into the name of this function. + // CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_linkagev + used_inline_module_linkage(); + + // FIXME: The module name should be mangled into the name of this function. + // CHECK: declare {{.*}}@_Z24noninline_module_linkagev + noninline_module_linkage(); +} diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm new file mode 100644 index 00000000000..be3644efa5b --- /dev/null +++ b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm @@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s --implicit-check-not=unused + +static void unused_static_global_module() {} +static void used_static_global_module() {} +inline void unused_inline_global_module() {} +inline void used_inline_global_module() {} +// CHECK: define void {{.*}}@_Z23noninline_global_modulev +void noninline_global_module() { + // FIXME: This should be promoted to module linkage and given a + // module-mangled name, if it's called from an inline function within + // the module interface. + // (We should try to avoid this when it's not reachable from outside + // the module interface unit.) + // CHECK: define internal {{.*}}@_ZL25used_static_global_modulev + used_static_global_module(); + // CHECK: define linkonce_odr {{.*}}@_Z25used_inline_global_modulev + used_inline_global_module(); +} + +export module Module; + +export { + // FIXME: These should be ill-formed: you can't export an internal linkage + // symbol, per [dcl.module.interface]p2. + static void unused_static_exported() {} + static void used_static_exported() {} + + inline void unused_inline_exported() {} + inline void used_inline_exported() {} + // CHECK: define void {{.*}}@_Z18noninline_exportedv + void noninline_exported() { + // CHECK: define internal {{.*}}@_ZL20used_static_exportedv + used_static_exported(); + // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv + used_inline_exported(); + } +} + +static void unused_static_module_linkage() {} +static void used_static_module_linkage() {} +inline void unused_inline_module_linkage() {} +inline void used_inline_module_linkage() {} +// FIXME: The module name should be mangled into the name of this function. +// CHECK: define void {{.*}}@_Z24noninline_module_linkagev +void noninline_module_linkage() { + // FIXME: This should be promoted to module linkage and given a + // module-mangled name, if it's called from an inline function within + // the module interface. + // CHECK: define internal {{.*}}@_ZL26used_static_module_linkagev + used_static_module_linkage(); + // FIXME: The module name should be mangled into the name of this function. + // CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_linkagev + used_inline_module_linkage(); +} diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp new file mode 100644 index 00000000000..bbd67e2c89a --- /dev/null +++ b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t +// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module + +import Module; + +void use() { + // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv + used_inline_exported(); + // CHECK: declare {{.*}}@_Z18noninline_exportedv + noninline_exported(); + + // Module-linkage declarations are not visible here. +} |