Skip to content

Commit 0c9c606

Browse files
committed
Remove MergePartialModules from SILOptions
Its use in deserialization can be replaced with a more general check for whether we're deserializing into the same module. Its use in the SILVerifier is subsumed by the check for whether the SILModule is canonical, which it isn't during merge-modules.
1 parent b3dcef9 commit 0c9c606

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

include/swift/AST/SILOptions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class SILOptions {
4040
/// Controls the aggressiveness of the loop unroller.
4141
int UnrollThreshold = 250;
4242

43-
/// Controls whether to pull in SIL from partial modules during the
44-
/// merge modules step. Could perhaps be merged with the link mode
45-
/// above but the interactions between all the flags are tricky.
46-
bool MergePartialModules = false;
47-
4843
/// Remove all runtime assertions during optimizations.
4944
bool RemoveRuntimeAsserts = false;
5045

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
10491049
if (FEOpts.RequestedAction == FrontendOptions::ActionType::EmitModuleOnly)
10501050
Opts.StopOptimizationAfterSerialization = true;
10511051

1052-
if (Args.hasArg(OPT_sil_merge_partial_modules))
1053-
Opts.MergePartialModules = true;
1054-
10551052
// Propagate the typechecker's understanding of
10561053
// -experimental-skip-non-inlinable-function-bodies to SIL.
10571054
Opts.SkipNonInlinableFunctionBodies = TCOpts.SkipNonInlinableFunctionBodies;

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,8 +1751,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
17511751
"[dynamically_replaceable] function");
17521752

17531753
// In canonical SIL, direct reference to a shared_external declaration
1754-
// is an error; we should have deserialized a body. In raw SIL, we may
1755-
// not have deserialized the body yet.
1754+
// is an error; we should have deserialized a body. In raw SIL, including
1755+
// the merge-modules phase, we may not have deserialized the body yet as we
1756+
// may not have run the SILLinker pass.
17561757
if (F.getModule().getStage() >= SILStage::Canonical) {
17571758
if (RefF->isExternalDeclaration()) {
17581759
require(SingleFunction ||
@@ -5560,20 +5561,13 @@ void SILModule::verify() const {
55605561
// Uniquing set to catch symbol name collisions.
55615562
llvm::DenseSet<StringRef> symbolNames;
55625563

5563-
// When merging partial modules, we only link functions from the current
5564-
// module, without enabling "LinkAll" mode or running the SILLinker pass;
5565-
// in this case, we need to relax some of the checks.
5566-
bool SingleFunction = false;
5567-
if (getOptions().MergePartialModules)
5568-
SingleFunction = true;
5569-
55705564
// Check all functions.
55715565
for (const SILFunction &f : *this) {
55725566
if (!symbolNames.insert(f.getName()).second) {
55735567
llvm::errs() << "Symbol redefined: " << f.getName() << "!\n";
55745568
assert(false && "triggering standard assertion failure routine");
55755569
}
5576-
f.verify(SingleFunction);
5570+
f.verify(/*singleFunction*/ false);
55775571
}
55785572

55795573
// Check all globals.

lib/Serialization/DeserializeSIL.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,13 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
597597

598598
fn->setSerialized(IsSerialized_t(isSerialized));
599599

600-
if (SILMod.getOptions().MergePartialModules)
600+
// If the serialized function comes from the same module, we're merging
601+
// modules, and can update the the linkage directly. This is needed to
602+
// correctly update the linkage for forward declarations to entities defined
603+
// in another file of the same module – we want to ensure the linkage
604+
// reflects the fact that the entity isn't really external and shouldn't be
605+
// dropped from the resulting merged module.
606+
if (getFile()->getParentModule() == SILMod.getSwiftModule())
601607
fn->setLinkage(linkage);
602608

603609
// Don't override the transparency or linkage of a function with

0 commit comments

Comments
 (0)