mirror of
https://github.com/apple/swift.git
synced 2025-12-25 12:15:36 +01:00
Add a small verification method that checks that we run our function analysis only on functions with bodies (not on external definitions). I ran into this bug when working on the pass manager.
63 lines
2.0 KiB
C++
63 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/BasicCalleeAnalysis.h"
|
|
#include "swift/SILAnalysis/DominanceAnalysis.h"
|
|
#include "swift/SILAnalysis/IVAnalysis.h"
|
|
#include "swift/SILAnalysis/PostOrderAnalysis.h"
|
|
#include "swift/SILAnalysis/CallGraphAnalysis.h"
|
|
#include "swift/SILAnalysis/ClassHierarchyAnalysis.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;
|
|
|
|
void SILAnalysis::verifyFunction(SILFunction *F) {
|
|
// Only functions with bodies can be analyzed by the analysis.
|
|
assert(F->isDefinition() && "Can't analyze external functions");
|
|
}
|
|
|
|
SILAnalysis *swift::createCallGraphAnalysis(SILModule *M) {
|
|
return new CallGraphAnalysis(M);
|
|
}
|
|
|
|
SILAnalysis *swift::createDominanceAnalysis(SILModule *) {
|
|
return new DominanceAnalysis();
|
|
}
|
|
|
|
SILAnalysis *swift::createPostDominanceAnalysis(SILModule *) {
|
|
return new PostDominanceAnalysis();
|
|
}
|
|
|
|
SILAnalysis *swift::createInductionVariableAnalysis(SILModule *M) {
|
|
return new IVAnalysis(M);
|
|
}
|
|
|
|
SILAnalysis *swift::createPostOrderAnalysis(SILModule *M) {
|
|
return new PostOrderAnalysis();
|
|
}
|
|
|
|
SILAnalysis *swift::createClassHierarchyAnalysis(SILModule *M) {
|
|
return new ClassHierarchyAnalysis(M);
|
|
}
|
|
|
|
SILAnalysis *swift::createBasicCalleeAnalysis(SILModule *M) {
|
|
return new BasicCalleeAnalysis(M);
|
|
}
|