| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: cd %t |
| 4 |
|
| 5 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 N.cpp \ |
| 6 |
// RUN: -emit-module-interface -o N.pcm |
| 7 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 N.pcm -emit-llvm \ |
| 8 |
// RUN: -o - | FileCheck %s --check-prefix=CHECK-N |
| 9 |
|
| 10 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.cpp \ |
| 11 |
// RUN: -emit-module-interface -o O.pcm |
| 12 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.pcm -emit-llvm \ |
| 13 |
// RUN: -o - | FileCheck %s --check-prefix=CHECK-O |
| 14 |
|
| 15 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-Part.cpp \ |
| 16 |
// RUN: -emit-module-interface -o M-Part.pcm |
| 17 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-Part.pcm \ |
| 18 |
// RUN: -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-P |
| 19 |
|
| 20 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M.cpp \ |
| 21 |
// RUN: -fprebuilt-module-path=%t -emit-module-interface -o M.pcm |
| 22 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M.pcm -emit-llvm \ |
| 23 |
// RUN: -fprebuilt-module-path=%t -o - | FileCheck %s --check-prefix=CHECK-M |
| 24 |
|
| 25 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 useM.cpp \ |
| 26 |
// RUN: -fprebuilt-module-path=%t -emit-llvm -o - \ |
| 27 |
// RUN: | FileCheck %s --check-prefix=CHECK-USE |
| 28 |
|
| 29 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-impl.cpp \ |
| 30 |
// RUN: -fprebuilt-module-path=%t -emit-llvm -o - \ |
| 31 |
// RUN: | FileCheck %s --check-prefix=CHECK-IMPL |
| 32 |
|
| 33 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 N.cpp -emit-llvm \ |
| 34 |
// RUN: -o - | FileCheck %s --check-prefix=CHECK-N |
| 35 |
|
| 36 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.cpp -emit-llvm \ |
| 37 |
// RUN: -o - | FileCheck %s --check-prefix=CHECK-O |
| 38 |
|
| 39 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-Part.cpp -emit-llvm \ |
| 40 |
// RUN: -o - | FileCheck %s --check-prefix=CHECK-P |
| 41 |
|
| 42 |
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M.cpp \ |
| 43 |
// RUN: -fprebuilt-module-path=%t -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-M |
| 44 |
|
| 45 |
//--- N-h.h |
| 46 |
|
| 47 |
struct Oink { |
| 48 |
Oink(){}; |
| 49 |
}; |
| 50 |
|
| 51 |
Oink Hog; |
| 52 |
|
| 53 |
//--- N.cpp |
| 54 |
|
| 55 |
module; |
| 56 |
#include "N-h.h" |
| 57 |
|
| 58 |
export module N; |
| 59 |
|
| 60 |
export struct Quack { |
| 61 |
Quack(){}; |
| 62 |
}; |
| 63 |
|
| 64 |
export Quack Duck; |
| 65 |
|
| 66 |
// CHECK-N: define internal void @__cxx_global_var_init |
| 67 |
// CHECK-N: call {{.*}} @_ZN4OinkC1Ev |
| 68 |
// CHECK-N: define internal void @__cxx_global_var_init |
| 69 |
// CHECK-N: call {{.*}} @_ZNW1N5QuackC1Ev |
| 70 |
// CHECK-N: define void @_ZGIW1N |
| 71 |
// CHECK-N: store i8 1, ptr @_ZGIW1N__in_chrg |
| 72 |
// CHECK-N: call void @__cxx_global_var_init |
| 73 |
// CHECK-N: call void @__cxx_global_var_init |
| 74 |
|
| 75 |
//--- O-h.h |
| 76 |
|
| 77 |
struct Meow { |
| 78 |
Meow(){}; |
| 79 |
}; |
| 80 |
|
| 81 |
Meow Cat; |
| 82 |
|
| 83 |
//--- O.cpp |
| 84 |
|
| 85 |
module; |
| 86 |
#include "O-h.h" |
| 87 |
|
| 88 |
export module O; |
| 89 |
|
| 90 |
export struct Bark { |
| 91 |
Bark(){}; |
| 92 |
}; |
| 93 |
|
| 94 |
export Bark Dog; |
| 95 |
|
| 96 |
// CHECK-O: define internal void @__cxx_global_var_init |
| 97 |
// CHECK-O: call {{.*}} @_ZN4MeowC2Ev |
| 98 |
// CHECK-O: define internal void @__cxx_global_var_init |
| 99 |
// CHECK-O: call {{.*}} @_ZNW1O4BarkC1Ev |
| 100 |
// CHECK-O: define void @_ZGIW1O |
| 101 |
// CHECK-O: store i8 1, ptr @_ZGIW1O__in_chrg |
| 102 |
// CHECK-O: call void @__cxx_global_var_init |
| 103 |
// CHECK-O: call void @__cxx_global_var_init |
| 104 |
|
| 105 |
//--- P-h.h |
| 106 |
|
| 107 |
struct Croak { |
| 108 |
Croak(){}; |
| 109 |
}; |
| 110 |
|
| 111 |
Croak Frog; |
| 112 |
|
| 113 |
//--- M-Part.cpp |
| 114 |
|
| 115 |
module; |
| 116 |
#include "P-h.h" |
| 117 |
|
| 118 |
module M:Part; |
| 119 |
|
| 120 |
struct Squawk { |
| 121 |
Squawk(){}; |
| 122 |
}; |
| 123 |
|
| 124 |
Squawk parrot; |
| 125 |
|
| 126 |
// CHECK-P: define internal void @__cxx_global_var_init |
| 127 |
// CHECK-P: call {{.*}} @_ZN5CroakC1Ev |
| 128 |
// CHECK-P: define internal void @__cxx_global_var_init |
| 129 |
// CHECK-P: call {{.*}} @_ZNW1M6SquawkC1Ev |
| 130 |
// CHECK-P: define void @_ZGIW1MWP4Part |
| 131 |
// CHECK-P: store i8 1, ptr @_ZGIW1MWP4Part__in_chrg |
| 132 |
// CHECK-P: call void @__cxx_global_var_init |
| 133 |
// CHECK-P: call void @__cxx_global_var_init |
| 134 |
|
| 135 |
//--- M-h.h |
| 136 |
|
| 137 |
struct Moo { |
| 138 |
Moo(){}; |
| 139 |
}; |
| 140 |
|
| 141 |
Moo Cow; |
| 142 |
|
| 143 |
//--- M.cpp |
| 144 |
|
| 145 |
module; |
| 146 |
#include "M-h.h" |
| 147 |
|
| 148 |
export module M; |
| 149 |
import N; |
| 150 |
export import O; |
| 151 |
import :Part; |
| 152 |
|
| 153 |
export struct Baa { |
| 154 |
int x; |
| 155 |
Baa(){}; |
| 156 |
Baa(int x) : x(x) {} |
| 157 |
int getX() { return x; } |
| 158 |
}; |
| 159 |
|
| 160 |
export Baa Sheep(10); |
| 161 |
|
| 162 |
// CHECK-M: define internal void @__cxx_global_var_init |
| 163 |
// CHECK-M: call {{.*}} @_ZN3MooC1Ev |
| 164 |
// CHECK-M: define internal void @__cxx_global_var_init |
| 165 |
// CHECK-M: call {{.*}} @_ZNW1M3BaaC1Ei |
| 166 |
// CHECK-M: declare void @_ZGIW1O() |
| 167 |
// CHECK-M: declare void @_ZGIW1N() |
| 168 |
// CHECK-M: declare void @_ZGIW1MWP4Part() |
| 169 |
// CHECK-M: define void @_ZGIW1M |
| 170 |
// CHECK-M: store i8 1, ptr @_ZGIW1M__in_chrg |
| 171 |
// CHECK-M: call void @_ZGIW1O() |
| 172 |
// CHECK-M: call void @_ZGIW1N() |
| 173 |
// CHECK-M: call void @_ZGIW1MWP4Part() |
| 174 |
// CHECK-M: call void @__cxx_global_var_init |
| 175 |
// CHECK-M: call void @__cxx_global_var_init |
| 176 |
|
| 177 |
//--- useM.cpp |
| 178 |
|
| 179 |
import M; |
| 180 |
|
| 181 |
int main() { |
| 182 |
return Sheep.getX(); |
| 183 |
} |
| 184 |
|
| 185 |
// CHECK-USE: declare void @_ZGIW1M |
| 186 |
// CHECK-USE: define internal void @_GLOBAL__sub_I_useM.cpp |
| 187 |
// CHECK-USE: call void @_ZGIW1M() |
| 188 |
|
| 189 |
//--- M-impl.cpp |
| 190 |
|
| 191 |
module M; |
| 192 |
|
| 193 |
int foo(int i) { return i + 1; } |
| 194 |
|
| 195 |
// CHECK-IMPL: declare void @_ZGIW1M |
| 196 |
// CHECK-IMPL: define internal void @_GLOBAL__sub_I_M_impl.cpp |
| 197 |
// CHECK-IMPL: call void @_ZGIW1M() |