Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Modules] Don't re-generate template specialization in the importer
Close #60693. In this issue, we can find that the importer will try to generate the template specialization again in the importer, which is not good and wastes time. This patch tries to address the problem.
- Loading branch information
1 parent
46cdf7f
commit 1ba93c3
Showing
5 changed files
with
63 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Address: https://github.com/llvm/llvm-project/issues/60693 | ||
// | ||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: split-file %s %t | ||
// | ||
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm -emit-module-interface -o %t/a.pcm | ||
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -fmodule-file=a=%t/a.pcm %t/c.cpp -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cpp | ||
|
||
//--- a.cppm | ||
export module a; | ||
|
||
constexpr bool f() { | ||
for (unsigned n = 0; n != 10; ++n) { | ||
} | ||
return true; | ||
} | ||
|
||
export template<typename> | ||
struct s { | ||
static constexpr auto a = f(); | ||
static constexpr auto b = f(); | ||
static constexpr auto c = f(); | ||
static constexpr auto d = f(); | ||
int foo() { | ||
return 43; | ||
} | ||
int bar() { | ||
return 44; | ||
} | ||
}; | ||
|
||
template struct s<int>; | ||
template struct s<long>; | ||
|
||
//--- c.cpp | ||
import a; | ||
|
||
extern "C" int use() { | ||
s<int> _; | ||
return _.a + _.b + _.c + _.d; | ||
} | ||
|
||
extern "C" long use2() { | ||
s<long> _; | ||
return _.foo(); | ||
} | ||
|
||
// CHECK: define{{.*}}@use( | ||
// CHECK-NOT: } | ||
// CHECK: ret{{.*}} 4 | ||
|
||
// CHECK: declare{{.*}}@_ZNW1a1sIlE3fooEv | ||
// CHECK-NOT: _ZNW1a1sIlE3barEv |