2 REQUIRES: x86-registered-target
4 RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen-opt/foo.modulemap -o %t/foo.pcm
5 RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=bar %S/Inputs/codegen-opt/bar.modulemap -o %t/bar.pcm -fmodule-file=%t/foo.pcm
7 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO %s
8 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/bar.pcm -fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN --check-prefix=BAR %s
9 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm %S/Inputs/codegen-opt/use.cpp | FileCheck --check-prefix=USE-CMN --check-prefix=USE %s
11 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 -disable-llvm-passes %t/foo.pcm | FileCheck --check-prefix=FOO %s
12 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 -disable-llvm-passes %t/bar.pcm -fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN --check-prefix=BAR-OPT %s
13 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 -disable-llvm-passes -fmodules -fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm %S/Inputs/codegen-opt/use.cpp | FileCheck --check-prefix=USE-CMN --check-prefix=USE-OPT %s
16 FOO: $_Z3foov = comdat any
17 FOO: $_Z4foo2v = comdat any
18 FOO: $_ZZ3foovE1i = comdat any
19 FOO: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
20 FOO-NOT: {{comdat|define|declare}}
21 FOO: define{{.*}} void @_Z7foo_extv()
22 FOO-NOT: {{define|declare}}
23 FOO: define weak_odr void @_Z3foov() #{{[0-9]+}} comdat
24 FOO-NOT: {{define|declare}}
25 FOO: declare void @_Z2f1Ri(ptr
26 FOO-NOT: {{define|declare}}
28 Internal functions are not modularly code generated - they are
29 internal wherever they're used. This might not be ideal, but
30 continues to workaround/support some oddities that backwards
31 compatible modules have seen and supported in the wild. To remove
32 the duplication here, the internal functions would need to be
33 promoted to weak_odr, placed in comdat and given a new mangling -
34 this would be needed for the C++ Modules TS anyway.
35 FOO: define internal void @_ZL2f2v() #{{[0-9]+}}
36 FOO-NOT: {{define|declare}}
38 FOO: define weak_odr void @_Z4foo2v() #{{[0-9]+}} comdat
39 FOO-NOT: {{define|declare}}
43 BAR-CMN: $_Z3barv = comdat any
44 BAR-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
45 BAR-CMN-NOT: {{comdat|define|declare}}
46 BAR-CMN: define weak_odr void @_Z3barv() #{{[0-9]+}} comdat
47 BAR-CMN-NOT: {{define|declare}}
48 BAR: declare void @_Z3foov()
49 Include all the available_externally definitions required for bar (foo -> f2)
50 BAR-OPT: define available_externally void @_Z3foov()
51 BAR-CMN-NOT: {{define|declare}}
52 BAR-OPT: declare void @_Z2f1Ri(ptr
53 BAR-OPT-NOT: {{define|declare}}
54 BAR-OPT: define internal void @_ZL2f2v()
55 BAR-OPT-NOT: {{define|declare}}
58 USE-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
59 USE-CMN-NOT: {{comdat|define|declare}}
60 USE-CMN: define{{.*}} i32 @main()
61 USE-CMN-NOT: {{define|declare}}
62 USE: declare void @_Z3barv()
63 Include all the available_externally definitions required for main (bar -> foo -> f2)
64 USE-OPT: define available_externally void @_Z3barv()
65 USE-CMN-NOT: {{define|declare}}
66 USE-OPT: define available_externally void @_Z3foov()
67 USE-OPT-NOT: {{define|declare}}
68 USE-OPT: declare void @_Z2f1Ri(ptr
69 USE-OPT-NOT: {{define|declare}}
70 USE-OPT: define internal void @_ZL2f2v()
71 USE-OPT-NOT: {{define|declare}}