mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This ensures that if we have a bunch of passes in a row which modify the CFG, we do not continually rebuild the post order, while at the same time preserving the property of multiple passes which do not touch the CFG sharing the same post order, reverse post order rather than recomputing them. rdar://17654239 Swift SVN r19913
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
//===----- Analysis.cpp - Swift Analysis ----------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#define DEBUG_TYPE "sil-analysis"
|
|
#include "swift/SILAnalysis/Analysis.h"
|
|
#include "swift/SILAnalysis/DominanceAnalysis.h"
|
|
#include "swift/SILAnalysis/IVAnalysis.h"
|
|
#include "swift/SILAnalysis/PostOrderAnalysis.h"
|
|
#include "swift/AST/Module.h"
|
|
#include "swift/AST/SILOptions.h"
|
|
#include "swift/SIL/SILModule.h"
|
|
#include "swift/SIL/SILFunction.h"
|
|
#include "llvm/ADT/Statistic.h"
|
|
#include "llvm/Support/Debug.h"
|
|
#include "swift/SILPasses/Utils/Local.h"
|
|
|
|
using namespace swift;
|
|
|
|
// anchor for virtual D'tor
|
|
CompleteFunctions::~CompleteFunctions() {}
|
|
|
|
void CompleteFunctions::setComplete() {
|
|
CompleteFuncs.clear();
|
|
if (!IsModulePending)
|
|
for (auto &F : *M)
|
|
if (!PendingFuncs.count(&F))
|
|
CompleteFuncs.insert(&F);
|
|
|
|
PendingFuncs.clear();
|
|
IsModulePending = false;
|
|
}
|
|
|
|
/// \brief return a bottom-up function order.
|
|
const std::vector<SILFunction*> &CallGraphAnalysis::bottomUpCallGraphOrder() {
|
|
// If we haven't calculated the order before do it now.
|
|
if (!BottomUpFunctionOrder.size())
|
|
swift::bottomUpCallGraphOrder(M, BottomUpFunctionOrder);
|
|
|
|
return BottomUpFunctionOrder;
|
|
}
|
|
|
|
SILAnalysis *swift::createCallGraphAnalysis(SILModule *M) {
|
|
return new CallGraphAnalysis(M);
|
|
}
|
|
|
|
SILAnalysis *swift::createDominanceAnalysis(SILModule *M) {
|
|
return new DominanceAnalysis(M);
|
|
}
|
|
|
|
SILAnalysis *swift::createInductionVariableAnalysis(SILModule *M) {
|
|
return new IVAnalysis(M);
|
|
}
|
|
|
|
SILAnalysis *swift::createPostOrderAnalysis(SILModule *M) {
|
|
return new PostOrderAnalysis(M);
|
|
}
|