mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rename the existing pass to AccessedStorageAnalysisDumper. AccessedStorage is useful on its own as a utility without the analysis. We need a way to test the utility itself. Add test cases for the previous commit that introduced FindPhiStorageVisitor.
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
//===--- AccessedStorageAnalysisDumper.cpp - accessed storage anlaysis ----===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#define DEBUG_TYPE "sil-accessed-storage-analysys-dumper"
|
|
#include "swift/SIL/SILArgument.h"
|
|
#include "swift/SIL/SILFunction.h"
|
|
#include "swift/SIL/SILInstruction.h"
|
|
#include "swift/SIL/SILValue.h"
|
|
#include "swift/SILOptimizer/Analysis/AccessedStorageAnalysis.h"
|
|
#include "swift/SILOptimizer/PassManager/Passes.h"
|
|
#include "swift/SILOptimizer/PassManager/Transforms.h"
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
using namespace swift;
|
|
|
|
namespace {
|
|
|
|
/// Dumps per-function information on dynamically enforced formal accesses.
|
|
class AccessedStorageAnalysisDumper : public SILModuleTransform {
|
|
|
|
void run() override {
|
|
auto *analysis = PM->getAnalysis<AccessedStorageAnalysis>();
|
|
|
|
for (auto &fn : *getModule()) {
|
|
llvm::outs() << "@" << fn.getName() << "\n";
|
|
if (fn.empty()) {
|
|
llvm::outs() << "<unknown>\n";
|
|
continue;
|
|
}
|
|
const FunctionAccessedStorage &summary = analysis->getEffects(&fn);
|
|
summary.print(llvm::outs());
|
|
}
|
|
}
|
|
};
|
|
|
|
} // end anonymous namespace
|
|
|
|
SILTransform *swift::createAccessedStorageAnalysisDumper() {
|
|
return new AccessedStorageAnalysisDumper();
|
|
}
|