1// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s --implicit-check-not unused_inline --implicit-check-not unused_stastic_global_module 2 3// CHECK-DAG: @extern_var_global_module = external global 4// CHECK-DAG: @inline_var_global_module = linkonce_odr global 5// CHECK-DAG: @_ZL24static_var_global_module = internal global 6// CHECK-DAG: @_ZL23const_var_global_module = internal constant 7// 8// For ABI compatibility, these symbols do not include the module name. 9// CHECK-DAG: @extern_var_exported = external global 10// FIXME: Should this be 'weak_odr global'? Presumably it must be, since we 11// can discard this global and its initializer (if any), and other TUs are not 12// permitted to run the initializer for this variable. 13// CHECK-DAG: @inline_var_exported = linkonce_odr global 14// CHECK-DAG: @_ZL19static_var_exported = global 15// CHECK-DAG: @const_var_exported = constant 16// 17// FIXME: The module name should be mangled into all of these. 18// CHECK-DAG: @extern_var_module_linkage = external global 19// FIXME: Should this be 'weak_odr global'? Presumably it must be, since we 20// can discard this global and its initializer (if any), and other TUs are not 21// permitted to run the initializer for this variable. 22// CHECK-DAG: @inline_var_module_linkage = linkonce_odr global 23// CHECK-DAG: @_ZL25static_var_module_linkage = global 24// CHECK-DAG: @_ZL24const_var_module_linkage = constant 25 26static void unused_static_global_module() {} 27static void used_static_global_module() {} 28 29inline void unused_inline_global_module() {} 30inline void used_inline_global_module() {} 31 32extern int extern_var_global_module; 33inline int inline_var_global_module; 34static int static_var_global_module; 35const int const_var_global_module = 3; 36 37// CHECK: define void {{.*}}@_Z23noninline_global_modulev 38void noninline_global_module() { 39 // FIXME: This should be promoted to module linkage and given a 40 // module-mangled name, if it's called from an inline function within 41 // the module interface. 42 // (We should try to avoid this when it's not reachable from outside 43 // the module interface unit.) 44 // CHECK: define internal {{.*}}@_ZL25used_static_global_modulev 45 used_static_global_module(); 46 // CHECK: define linkonce_odr {{.*}}@_Z25used_inline_global_modulev 47 used_inline_global_module(); 48 49 (void)&extern_var_global_module; 50 (void)&inline_var_global_module; 51 (void)&static_var_global_module; 52 (void)&const_var_global_module; 53} 54 55export module Module; 56 57export { 58 // FIXME: These should be ill-formed: you can't export an internal linkage 59 // symbol, per [dcl.module.interface]p2. 60 // CHECK: define void {{.*}}@_ZL22unused_static_exportedv 61 static void unused_static_exported() {} 62 // CHECK: define void {{.*}}@_ZL20used_static_exportedv 63 static void used_static_exported() {} 64 65 inline void unused_inline_exported() {} 66 inline void used_inline_exported() {} 67 68 extern int extern_var_exported; 69 inline int inline_var_exported; 70 // FIXME: This should be ill-formed: you can't export an internal linkage 71 // symbol. 72 static int static_var_exported; 73 const int const_var_exported = 3; 74 75 // CHECK: define void {{.*}}@_Z18noninline_exportedv 76 void noninline_exported() { 77 used_static_exported(); 78 // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv 79 used_inline_exported(); 80 81 (void)&extern_var_exported; 82 (void)&inline_var_exported; 83 (void)&static_var_exported; 84 (void)&const_var_exported; 85 } 86} 87 88// FIXME: Ideally we wouldn't emit this as its name is not visible outside this 89// TU, but this module interface might contain a template that can use this 90// function so we conservatively emit it for now. 91// FIXME: The module name should be mangled into the name of this function. 92// CHECK: define void {{.*}}@_ZL28unused_static_module_linkagev 93static void unused_static_module_linkage() {} 94// FIXME: The module name should be mangled into the name of this function. 95// CHECK: define void {{.*}}@_ZL26used_static_module_linkagev 96static void used_static_module_linkage() {} 97 98inline void unused_inline_module_linkage() {} 99inline void used_inline_module_linkage() {} 100 101extern int extern_var_module_linkage; 102inline int inline_var_module_linkage; 103static int static_var_module_linkage; 104const int const_var_module_linkage = 3; 105 106// FIXME: The module name should be mangled into the name of this function. 107// CHECK: define void {{.*}}@_Z24noninline_module_linkagev 108void noninline_module_linkage() { 109 used_static_module_linkage(); 110 // FIXME: The module name should be mangled into the name of this function. 111 // CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_linkagev 112 used_inline_module_linkage(); 113 114 (void)&extern_var_module_linkage; 115 (void)&inline_var_module_linkage; 116 (void)&static_var_module_linkage; 117 (void)&const_var_module_linkage; 118} 119