Close https://github.com/llvm/llvm-project/issues/71034 See https://discourse.llvm.org/t/rfc-c-20-modules-introduce-thin-bmi-and-decls-hash/74755 This patch introduces reduced BMI, which doesn't contain the definitions of functions and variables if its definitions won't contribute to the ABI. Testing is a big part of the patch. We want to make sure the reduced BMI contains the same behavior with the existing and relatively stable fatBMI. This is pretty helpful for further reduction. The user interfaces part it left to following patches to ease the reviewing.
38 lines
1.5 KiB
C++
38 lines
1.5 KiB
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions %t/mod.cppm -emit-module-interface \
|
|
// RUN: -o %t/mod.pcm
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions %t/mod.pcm -S -emit-llvm -o - | \
|
|
// RUN: FileCheck %t/mod.cppm
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions %t/user.cpp -fmodule-file=mod=%t/mod.pcm \
|
|
// RUN: -S -emit-llvm -o - | FileCheck %t/user.cpp
|
|
|
|
// Test again with reduced BMI
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions %t/mod.cppm -emit-reduced-module-interface \
|
|
// RUN: -o %t/mod.pcm
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions %t/mod.pcm -S -emit-llvm -o - | \
|
|
// RUN: FileCheck %t/mod.cppm
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions %t/user.cpp -fmodule-file=mod=%t/mod.pcm \
|
|
// RUN: -S -emit-llvm -o - | FileCheck %t/user.cpp
|
|
|
|
//--- mod.cppm
|
|
module;
|
|
|
|
#pragma comment(lib, "msvcprt.lib")
|
|
#pragma detect_mismatch("myLib_version", "9")
|
|
|
|
export module mod;
|
|
|
|
// CHECK: ![[NUM:[0-9]+]] ={{.*}}msvcprt.lib
|
|
// CHECK: ![[NUM:[0-9]+]] ={{.*}}FAILIFMISMATCH{{.*}}myLib_version=9
|
|
|
|
//--- user.cpp
|
|
#pragma detect_mismatch("myLib_version", "1")
|
|
import mod;
|
|
|
|
// CHECK: ![[NUM:[0-9]+]] ={{.*}}FAILIFMISMATCH{{.*}}myLib_version=1
|
|
// CHECK: ![[NUM:[0-9]+]] ={{.*}}msvcprt.lib
|
|
// CHECK: ![[NUM:[0-9]+]] ={{.*}}FAILIFMISMATCH{{.*}}myLib_version=9
|