1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/parta.cppm -o %t/mod-parta.pcm
6 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/partb.cppm -o %t/mod-partb.pcm
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple -fmodule-file=%t/mod-parta.pcm \
8 // RUN:     -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm
9 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \
10 // RUN:     | FileCheck %t/mod.cppm
11 // RUN: %clang_cc1 -std=c++20 -O2 -emit-module-interface -triple %itanium_abi_triple -fmodule-file=%t/mod-parta.pcm \
12 // RUN:     -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm
13 // RUN: %clang_cc1 -std=c++20 -O2 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \
14 // RUN:     | FileCheck %t/mod.cppm  -check-prefix=CHECK-OPT
15 
16 //--- parta.cppm
17 export module mod:parta;
18 
19 export int a = 43;
20 
foo()21 export int foo() {
22   return 3 + a;
23 }
24 
25 //--- partb.cppm
26 module mod:partb;
27 
28 int b = 43;
29 
bar()30 int bar() {
31   return 43 + b;
32 }
33 
34 //--- mod.cppm
35 export module mod;
36 import :parta;
37 import :partb;
use()38 export int use() {
39   return foo() + bar() + a + b;
40 }
41 
42 // CHECK: @_ZW3mod1a = available_externally global
43 // CHECK: @_ZW3mod1b = available_externally global
44 // CHECK: declare{{.*}} i32 @_ZW3mod3foov
45 // CHECK: declare{{.*}} i32 @_ZW3mod3barv
46 
47 // CHECK-OPT: @_ZW3mod1a = available_externally global
48 // CHECK-OPT: @_ZW3mod1b = available_externally global
49 // CHECK-OPT: define available_externally{{.*}} i32 @_ZW3mod3foov
50 // CHECK-OPT: define available_externally{{.*}} i32 @_ZW3mod3barv
51