mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The old invalidation lattice was incorrect because changes to control flow could cause changes to the call graph, so we've decided to change the way passes invalidate analysis. In the new scheme, the lattice is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches. Now, passes report which traits they preserve, which is the opposite of the previous implementation where passes needed to report what they invalidate. Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some of the code in a following commit. Swift SVN r26449
62 lines
1.7 KiB
C++
62 lines
1.7 KiB
C++
//===--- Link.cpp - Link in transparent SILFunctions from module ----------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "swift/SILPasses/Passes.h"
|
|
#include "swift/SILPasses/Transforms.h"
|
|
#include "swift/SIL/SILModule.h"
|
|
|
|
using namespace swift;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Top Level Driver
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
void swift::performSILLinking(SILModule *M, bool LinkAll) {
|
|
auto LinkMode = LinkAll? SILModule::LinkingMode::LinkAll :
|
|
SILModule::LinkingMode::LinkNormal;
|
|
for (auto &Fn : *M)
|
|
M->linkFunction(&Fn, LinkMode);
|
|
|
|
if (!LinkAll)
|
|
return;
|
|
|
|
M->linkAllWitnessTables();
|
|
M->linkAllVTables();
|
|
}
|
|
|
|
|
|
namespace {
|
|
|
|
class SILLinker : public SILModuleTransform {
|
|
|
|
/// The entry point to the transformation.
|
|
void run() override {
|
|
// Copies code from the standard library into the user program to enable
|
|
// optimizations.
|
|
bool Changed = false;
|
|
SILModule &M = *getModule();
|
|
for (auto &Fn : M)
|
|
Changed |= M.linkFunction(&Fn, SILModule::LinkingMode::LinkAll);
|
|
|
|
if (Changed)
|
|
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
|
}
|
|
|
|
StringRef getName() override { return "SIL Linker"; }
|
|
};
|
|
} // end anonymous namespace
|
|
|
|
|
|
SILTransform *swift::createSILLinker() {
|
|
return new SILLinker();
|
|
}
|