brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · eafd47a Raw
72 lines · plain
1RUN: rm -rf %t2REQUIRES: x86-registered-target3 4RUN: %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.pcm5RUN: %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.pcm6 7RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO %s8RUN: %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 %s9RUN: %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 %s10 11RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 -disable-llvm-passes %t/foo.pcm | FileCheck --check-prefix=FOO %s12RUN: %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 %s13RUN: %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 %s14 15FOO-NOT: comdat16FOO: $_Z3foov = comdat any17FOO: $_Z4foo2v = comdat any18FOO: $_ZZ3foovE1i = comdat any19FOO: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat20FOO-NOT: {{comdat|define|declare}}21FOO: define{{.*}} void @_Z7foo_extv()22FOO-NOT: {{define|declare}}23FOO: define weak_odr void @_Z3foov() #{{[0-9]+}} comdat24FOO-NOT: {{define|declare}}25FOO: declare void @_Z2f1Ri(ptr26FOO-NOT: {{define|declare}}27 28Internal functions are not modularly code generated - they are29internal wherever they're used. This might not be ideal, but30continues to workaround/support some oddities that backwards31compatible modules have seen and supported in the wild.  To remove32the duplication here, the internal functions would need to be33promoted to weak_odr, placed in comdat and given a new mangling -34this would be needed for the C++ Modules TS anyway.35FOO: define internal void @_ZL2f2v() #{{[0-9]+}}36FOO-NOT: {{define|declare}}37 38FOO: define weak_odr void @_Z4foo2v() #{{[0-9]+}} comdat39FOO-NOT: {{define|declare}}40 41 42BAR-CMN-NOT: comdat43BAR-CMN: $_Z3barv = comdat any44BAR-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat45BAR-CMN-NOT: {{comdat|define|declare}}46BAR-CMN: define weak_odr void @_Z3barv() #{{[0-9]+}} comdat47BAR-CMN-NOT: {{define|declare}}48BAR: declare void @_Z3foov()49Include all the available_externally definitions required for bar (foo -> f2)50BAR-OPT: define available_externally void @_Z3foov()51BAR-CMN-NOT: {{define|declare}}52BAR-OPT: declare void @_Z2f1Ri(ptr53BAR-OPT-NOT: {{define|declare}}54BAR-OPT: define internal void @_ZL2f2v()55BAR-OPT-NOT: {{define|declare}}56 57 58USE-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat59USE-CMN-NOT: {{comdat|define|declare}}60USE-CMN: define{{.*}} i32 @main()61USE-CMN-NOT: {{define|declare}}62USE: declare void @_Z3barv()63Include all the available_externally definitions required for main (bar -> foo -> f2)64USE-OPT: define available_externally void @_Z3barv()65USE-CMN-NOT: {{define|declare}}66USE-OPT: define available_externally void @_Z3foov()67USE-OPT-NOT: {{define|declare}}68USE-OPT: declare void @_Z2f1Ri(ptr69USE-OPT-NOT: {{define|declare}}70USE-OPT: define internal void @_ZL2f2v()71USE-OPT-NOT: {{define|declare}}72