1RUN: rm -rf %t
2REQUIRES: x86-registered-target
3
4RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -fmodules-debuginfo -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
5
6RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
7RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -fmodules -disable-llvm-passes -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
8
9
10For want of any better definition, inline asm goes "everywhere" the same as it
11if it were in a header (with the disadvantage that the inline asm will be
12included in the program if the module is used, even if the header containing
13the inline asm is never included - unlike a non-modular build).
14
15This is inconsistent with how namespace scope static variables are handled -
16where they only appear in the code that includes a header. This functionality
17was implemented to workaround/support the initialization of iostreams
18(implemented as a namespace scope static in the header - only to be provided
19when that specific header is included in the program).
20
21BOTH: module asm "narf"
22
23FOO: $_Z2f1PKcz = comdat any
24FOO: $_ZN13implicit_dtorD1Ev = comdat any
25USE: $_Z4instIiEvv = comdat any
26USE: $_Z10always_inlv = comdat any
27FOO: $_ZN13implicit_dtorD2Ev = comdat any
28FOO: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
29FOO:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
30
31Test that implicit special members are emitted into the FOO module if they're
32ODR used there, otherwise emit them linkonce_odr as usual in the use.
33
34FIXME: Proactively instantiate any valid implicit special members to emit them into the module object.
35
36FOO: define weak_odr void @_ZN13implicit_dtorD1Ev
37FOO: define weak_odr void @_Z4instIfEvv
38FOO: define weak_odr void @_ZN13implicit_dtorD2Ev
39
40USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev
41USE: define linkonce_odr void @_Z4instIiEvv
42USE: define linkonce_odr void @_Z10always_inlv
43USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev
44
45Modular debug info puts the definition of a class defined in a module in that
46module's object. Users of the module only get a declaration.
47
48'distinct' is used for definition records (the flags field is empty/unspecified)
49FOO: = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "implicit_dtor"
50Declarations are non-distinct and include the 'DIFlagFwdDecl' flag.
51USE: = !DICompositeType(tag: DW_TAG_structure_type, name: "implicit_dtor", {{.*}}, flags: DIFlagFwdDecl
52