2 // RUN: split-file %s %t
4 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/M.cppm \
5 // RUN: -emit-module-interface -o %t/M.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t \
7 // RUN: -triple %itanium_abi_triple \
8 // RUN: -S -emit-llvm -o - -disable-llvm-passes \
9 // RUN: | FileCheck %t/Use.cpp --check-prefix=CHECK-O0
11 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -O1 %t/M.cppm \
12 // RUN: -emit-module-interface -o %t/M.pcm
13 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -O1 \
14 // RUN: -triple %itanium_abi_triple \
15 // RUN: -S -emit-llvm -o - -disable-llvm-passes | \
16 // RUN: FileCheck %t/Use.cpp --check-prefix=CHECK-O1
22 int func_in_gmf_not_called() {
30 int non_exported_func() {
31 return 43 + func_in_gmf();
33 export int exported_func() {
34 return non_exported_func();
37 int non_exported_func_not_called() {
40 export int func_not_called() {
41 return non_exported_func_not_called();
45 __attribute__((always_inline))
46 int always_inline_func() {
53 return exported_func() + always_inline_func();
56 // Checks that none of the function (except the always_inline_func) in the importees
57 // are generated in the importer's code.
58 // CHECK-O0: define{{.*}}_Z3usev(
59 // CHECK-O0: declare{{.*}}_ZW1M13exported_funcv(
60 // CHECK-O0: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
61 // CHECK-O0-NOT: func_in_gmf
62 // CHECK-O0-NOT: func_in_gmf_not_called
63 // CHECK-O0-NOT: non_exported_func
64 // CHECK-O0-NOT: non_exported_func_not_called
65 // CHECK-O0-NOT: func_not_called
67 // Checks that all the potentially called function in the importees are generated in the importer's code
68 // with available_externally attribute.
69 // CHECK-O1: define{{.*}}_Z3usev(
70 // CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M13exported_funcv(
71 // CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
72 // CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M17non_exported_funcv(
73 // CHECK-O1: define{{.*}}available_externally{{.*}}_Z11func_in_gmfv(
74 // CHECK-O1-NOT: func_in_gmf_not_called
75 // CHECK-O1-NOT: non_exported_func_not_called
76 // CHECK-O1-NOT: func_not_called