-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C++20] [Modules] Introduce -fgen-reduced-bmi
- Loading branch information
1 parent
37eb0d4
commit 8baafcd
Showing
9 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// It is annoying to handle different slash direction | ||
// in Windows and Linux. So we disable the test on Windows | ||
// here. | ||
// REQUIRES: !system-windows | ||
// On AIX, the default output for `-c` may be `.s` instead of `.o`, | ||
// which makes the test fail. So disable the test on AIX. | ||
// UNSUPPORTED: system-aix | ||
// | ||
// RUN: rm -rf %t && split-file %s %t && cd %t | ||
// | ||
// RUN: %clang -std=c++20 Hello.cppm -fmodule-output=Hello.pcm \ | ||
// RUN: -fexperimental-modules-reduced-bmi -c -o Hello.o -### 2>&1 | FileCheck Hello.cppm | ||
// | ||
// RUN: %clang -std=c++20 Hello.cppm \ | ||
// RUN: -fexperimental-modules-reduced-bmi -c -o Hello.o -### 2>&1 | \ | ||
// RUN: FileCheck Hello.cppm --check-prefix=CHECK-UNSPECIFIED | ||
// | ||
// RUN: %clang -std=c++20 Hello.cppm \ | ||
// RUN: -fexperimental-modules-reduced-bmi -c -### 2>&1 | \ | ||
// RUN: FileCheck Hello.cppm --check-prefix=CHECK-NO-O | ||
// | ||
// RUN: %clang -std=c++20 Hello.cppm \ | ||
// RUN: -fexperimental-modules-reduced-bmi -c -o AnotherName.o -### 2>&1 | \ | ||
// RUN: FileCheck Hello.cppm --check-prefix=CHECK-ANOTHER-NAME | ||
// | ||
// RUN: %clang -std=c++20 Hello.cppm --precompile -fexperimental-modules-reduced-bmi \ | ||
// RUN: -o Hello.full.pcm -### 2>&1 | FileCheck Hello.cppm \ | ||
// RUN: --check-prefix=CHECK-EMIT-MODULE-INTERFACE | ||
// | ||
// RUN: %clang -std=c++20 Hello.cc -fexperimental-modules-reduced-bmi -Wall -Werror \ | ||
// RUN: -c -o Hello.o -### 2>&1 | FileCheck Hello.cc | ||
|
||
//--- Hello.cppm | ||
export module Hello; | ||
|
||
// Test that we won't generate the emit-module-interface as 2 phase compilation model. | ||
// CHECK-NOT: -emit-module-interface | ||
// CHECK: "-fexperimental-modules-reduced-bmi" | ||
|
||
// CHECK-UNSPECIFIED: -fmodule-output=Hello.pcm | ||
|
||
// CHECK-NO-O: -fmodule-output=Hello.pcm | ||
// CHECK-ANOTHER-NAME: -fmodule-output=AnotherName.pcm | ||
|
||
// With `-emit-module-interface` specified, we should still see the `-emit-module-interface` | ||
// flag. | ||
// CHECK-EMIT-MODULE-INTERFACE: -emit-module-interface | ||
|
||
//--- Hello.cc | ||
|
||
// CHECK-NOT: "-fexperimental-modules-reduced-bmi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: split-file %s %t | ||
// | ||
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.reduced.pcm | ||
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -fexperimental-modules-reduced-bmi -fmodule-output=%t/a.pcm \ | ||
// RUN: -S -emit-llvm -o %t/a.ll | ||
// | ||
// Test that the generated BMI from `-fexperimental-modules-reduced-bmi -fmodule-output=` is same with | ||
// `-emit-reduced-module-interface`. | ||
// RUN: diff %t/a.reduced.pcm %t/a.pcm | ||
// | ||
// Test that we can consume the produced BMI correctly. | ||
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify | ||
// | ||
// RUN: rm -f %t/a.pcm | ||
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -fexperimental-modules-reduced-bmi -fmodule-output=%t/a.pcm \ | ||
// RUN: -emit-module-interface -o %t/a.full.pcm | ||
// RUN: diff %t/a.reduced.pcm %t/a.pcm | ||
// RUN: not diff %t/a.pcm %t/a.full.pcm | ||
// | ||
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify | ||
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.full.pcm -fsyntax-only -verify | ||
|
||
//--- a.cppm | ||
export module a; | ||
export int a() { | ||
return 43; | ||
} | ||
|
||
//--- b.cppm | ||
// Test that we can consume the produced BMI correctly as a smocking test. | ||
// expected-no-diagnostics | ||
export module b; | ||
import a; | ||
export int b() { return a(); } |