1// Address: https://github.com/llvm/llvm-project/issues/60693 2// 3// RUN: rm -rf %t 4// RUN: mkdir -p %t 5// RUN: split-file %s %t 6// 7// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm -emit-module-interface -o %t/a.pcm 8// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -fmodule-file=a=%t/a.pcm %t/c.cpp -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cpp 9 10// Test again with reduced BMI 11// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm 12// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -fmodule-file=a=%t/a.pcm %t/c.cpp -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cpp 13 14//--- a.cppm 15export module a; 16 17constexpr bool f() { 18 for (unsigned n = 0; n != 10; ++n) { 19 } 20 return true; 21} 22 23template <typename T> 24struct u { 25 T unit() { 26 return T(); 27 } 28}; 29 30export template<typename T> 31struct s { 32 static constexpr auto a = f(); 33 static constexpr auto b = f(); 34 static constexpr auto c = f(); 35 static constexpr auto d = f(); 36 int foo() { 37 return 43; 38 } 39 int bar() { 40 return 44; 41 } 42 T zoo() { 43 return u<T>().unit(); 44 } 45}; 46 47template struct s<int>; 48template struct s<long>; 49 50//--- c.cpp 51import a; 52 53extern "C" int use() { 54 s<int> _; 55 return _.a + _.b + _.c + _.d; 56} 57 58extern "C" long use2() { 59 s<long> _; 60 return _.foo(); 61} 62 63extern "C" long use3() { 64 s<long> _; 65 return _.zoo(); 66} 67 68// CHECK: define{{.*}}@use( 69// CHECK-NOT: } 70// CHECK: ret{{.*}} 4 71 72// CHECK: declare{{.*}}@_ZNW1a1sIlE3fooEv 73// CHECK-NOT: _ZNW1a1sIlE3barEv 74// CHECK: declare{{.*}}_ZNW1a1sIlE3zooEv 75