Skip to content

Commit aa27414

Browse files
committed
Revert "[C++20] [Modules] Don't import non-inline function bodies even if it is marked as always_inline"
This reverts commit 1ecbab5. See the discussion in #86893. The original commit receives too many complaints. Let's try to workaround the issue to give better user experiences.
1 parent 2347020 commit aa27414

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -3952,7 +3952,8 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
39523952
// behavior may break ABI compatibility of the current unit.
39533953
if (const Module *M = F->getOwningModule();
39543954
M && M->getTopLevelModule()->isNamedModule() &&
3955-
getContext().getCurrentNamedModule() != M->getTopLevelModule())
3955+
getContext().getCurrentNamedModule() != M->getTopLevelModule() &&
3956+
!F->hasAttr<AlwaysInlineAttr>())
39563957
return false;
39573958

39583959
if (F->hasAttr<NoInlineAttr>())

clang/test/CodeGenCXX/module-funcs-from-imports.cppm

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ int use() {
5353
return exported_func() + always_inline_func();
5454
}
5555

56-
// Checks that none of the function in the importees
56+
// Checks that none of the function (except the always_inline_func) in the importees
5757
// are generated in the importer's code.
5858
// CHECK-O0: define{{.*}}_Z3usev(
5959
// CHECK-O0: declare{{.*}}_ZW1M13exported_funcv(
60-
// CHECK-O0: declare{{.*}}_ZW1M18always_inline_funcv(
60+
// CHECK-O0: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
6161
// CHECK-O0-NOT: func_in_gmf
6262
// CHECK-O0-NOT: func_in_gmf_not_called
6363
// CHECK-O0-NOT: non_exported_func
@@ -68,7 +68,7 @@ int use() {
6868
// O0 to keep consistent ABI.
6969
// CHECK-O1: define{{.*}}_Z3usev(
7070
// CHECK-O1: declare{{.*}}_ZW1M13exported_funcv(
71-
// CHECK-O1: declare{{.*}}_ZW1M18always_inline_funcv(
71+
// CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
7272
// CHECK-O1-NOT: func_in_gmf
7373
// CHECK-O1-NOT: func_in_gmf_not_called
7474
// CHECK-O1-NOT: non_exported_func

0 commit comments

Comments
 (0)