Files
swift-mirror/lib/SILOptimizer/UtilityPasses/AccessedStorageAnalysisDumper.cpp
Andrew Trick 5091aee6f2 Add an AccessedStorageDumper pass to verify findAccessedStorage.
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.
2020-07-20 16:42:28 -07:00

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();
}