brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 850d0f6 Raw
98 lines · plain
1// RUN: rm -rf %t2// RUN: split-file %s %t3//4// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/M.cppm \5// RUN:    -emit-module-interface -o %t/M.pcm6// 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-O010//11// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -O1 %t/M.cppm \12// RUN:    -emit-module-interface -o %t/M.pcm13// 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-O117 18//--- foo.h19int func_in_gmf() {20    return 43;21}22int func_in_gmf_not_called() {23    return 44;24}25 26template <class T>27class A {28public:29    __attribute__((always_inline))30    inline constexpr int getValue() {31        return 43;32    }33 34    inline constexpr int getValue2() {35        return 43;36    }37};38 39extern template class A<char>;40 41//--- M.cppm42module;43#include "foo.h"44export module M;45int non_exported_func() {46    return 43 + func_in_gmf();47}48export int exported_func() {49    return non_exported_func();50}51 52int non_exported_func_not_called() {53    return 44;54}55export int func_not_called() {56    return non_exported_func_not_called();57}58 59export 60__attribute__((always_inline))61int always_inline_func() {62    return 45;63}64 65export using ::A;66 67//--- Use.cpp68import M;69int use() {70    A<char> a;71    return exported_func() + always_inline_func() +72           a.getValue() + a.getValue2();73}74 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_gmf81// CHECK-O0-NOT: func_in_gmf_not_called82// CHECK-O0-NOT: non_exported_func83// CHECK-O0-NOT: non_exported_func_not_called84// CHECK-O0-NOT: func_not_called85 86// Checks that the generated code within optimizations keep the same behavior with87// 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_gmf94// CHECK-O1-NOT: func_in_gmf_not_called95// CHECK-O1-NOT: non_exported_func96// CHECK-O1-NOT: non_exported_func_not_called97// CHECK-O1-NOT: func_not_called98