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: -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: -emit-llvm -o - -disable-llvm-passes | \
16 // RUN: FileCheck %t/Use.cpp --check-prefix=CHECK-O1
22 int func_in_gmf_not_called() {
29 __attribute__((always_inline))
30 inline constexpr int getValue() {
34 inline constexpr int getValue2() {
39 extern template class A<char>;
45 int non_exported_func() {
46 return 43 + func_in_gmf();
48 export int exported_func() {
49 return non_exported_func();
52 int non_exported_func_not_called() {
55 export int func_not_called() {
56 return non_exported_func_not_called();
60 __attribute__((always_inline))
61 int always_inline_func() {
71 return exported_func() + always_inline_func() +
72 a.getValue() + a.getValue2();
75 // CHECK-O0: define{{.*}}_Z3usev(
76 // CHECK-O0: declare{{.*}}_ZW1M13exported_funcv(
77 // CHECK-O0: declare{{.*}}_ZW1M18always_inline_funcv(
78 // CHECK-O0: define{{.*}}@_ZN1AIcE8getValueEv(
79 // CHECK-O0: declare{{.*}}@_ZN1AIcE9getValue2Ev(
80 // CHECK-O0-NOT: func_in_gmf
81 // CHECK-O0-NOT: func_in_gmf_not_called
82 // CHECK-O0-NOT: non_exported_func
83 // CHECK-O0-NOT: non_exported_func_not_called
84 // CHECK-O0-NOT: func_not_called
86 // Checks that the generated code within optimizations keep the same behavior with
87 // O0 to keep consistent ABI.
88 // CHECK-O1: define{{.*}}_Z3usev(
89 // CHECK-O1: declare{{.*}}_ZW1M13exported_funcv(
90 // CHECK-O1: declare{{.*}}_ZW1M18always_inline_funcv(
91 // CHECK-O1: define{{.*}}@_ZN1AIcE8getValueEv(
92 // CHECK-O1: declare{{.*}}@_ZN1AIcE9getValue2Ev(
93 // CHECK-O1-NOT: func_in_gmf
94 // CHECK-O1-NOT: func_in_gmf_not_called
95 // CHECK-O1-NOT: non_exported_func
96 // CHECK-O1-NOT: non_exported_func_not_called
97 // CHECK-O1-NOT: func_not_called