brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 7ca9f8d Raw
75 lines · plain
1// Address: https://github.com/llvm/llvm-project/issues/606932//3// RUN: rm -rf %t4// RUN: mkdir -p %t5// RUN: split-file %s %t6//7// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm -emit-module-interface -o %t/a.pcm8// 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.cpp9 10// Test again with reduced BMI11// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm12// 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.cpp13 14//--- a.cppm15export 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.cpp51import 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{{.*}} 471 72// CHECK: declare{{.*}}@_ZNW1a1sIlE3fooEv73// CHECK-NOT: _ZNW1a1sIlE3barEv74// CHECK: declare{{.*}}_ZNW1a1sIlE3zooEv75