Skip to content

Commit 6478256

Browse files
committed
SIL: Relax some verifier checks when merging partial modules
When merging partial SIL modules we only link in function bodies defined in the current module, so we might encounter functions with shared linkage and no body. Since pulling in these functions from other modules is a waste of time, run the verifier in "single function" mode in this case. Note that when the module is ultimately used and one of these functions is deserialized, we should link in all downstream functions with shared linkage, and failure to do so will be caught by the SIL verifier then. Fixes <rdar://problem/34469704>.
1 parent c28ade7 commit 6478256

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4516,13 +4516,20 @@ void SILModule::verify() const {
45164516
// Uniquing set to catch symbol name collisions.
45174517
llvm::StringSet<> symbolNames;
45184518

4519+
// When merging partial modules, we only link functions from the current
4520+
// module, without enabling "LinkAll" mode or running the SILLinker pass;
4521+
// in this case, we need to relax some of the checks.
4522+
bool SingleFunction = false;
4523+
if (getOptions().MergePartialModules)
4524+
SingleFunction = true;
4525+
45194526
// Check all functions.
45204527
for (const SILFunction &f : *this) {
45214528
if (!symbolNames.insert(f.getName()).second) {
45224529
llvm::errs() << "Symbol redefined: " << f.getName() << "!\n";
45234530
assert(false && "triggering standard assertion failure routine");
45244531
}
4525-
f.verify(/*SingleFunction=*/false);
4532+
f.verify(SingleFunction);
45264533
}
45274534

45284535
// Check all globals.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -emit-module -primary-file %s -module-name test -o %t/partial.swiftmodule -O
4+
5+
// RUN: %target-swift-frontend -emit-module %t/partial.swiftmodule -module-name test -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -o %t/test.swiftmodule
6+
7+
public func makeMirror(object x: Any) -> Mirror {
8+
return Mirror(reflecting: x)
9+
}

0 commit comments

Comments
 (0)