forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sil-bug-reducer] Create the sil-passpipeline-dumper tool.
This enables one to dump the various passpipelines in a yaml format. Other pretty print formats can be added in the future as well if desired. Its intended usage is to provide a source of pass pipeline information for external python bug-reducing tools. By integrating this as a compiler-tool, we are guaranteed to never have to update any of these tools in the face of passpipeline changes.
- Loading branch information
Showing
7 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %sil-passpipeline-dumper -Onone | %FileCheck %s | ||
// RUN: %sil-passpipeline-dumper -Onone | python -c 'import json; import sys; json.load(sys.stdin)' | ||
|
||
// CHECK: [ | ||
// CHECK: [ | ||
// CHECK: "Prespecialization", | ||
// CHECK: "until_fix_point", | ||
// CHECK: ["UsePrespecialized","use-prespecialized"] | ||
// CHECK: ], | ||
// CHECK: [ | ||
// CHECK: "Rest of Onone", | ||
// CHECK: "one_iteration", | ||
// CHECK: ["ExternalDefsToDecls","external-defs-to-decls"], | ||
// CHECK: ["AssumeSingleThreaded","sil-assume-single-threaded"], | ||
// CHECK: ["SILDebugInfoGenerator","sil-debuginfo-gen"] | ||
// CHECK: ] | ||
// CHECK: ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
add_swift_host_tool(sil-passpipeline-dumper | ||
SILPassPipelineDumper.cpp | ||
LINK_LIBRARIES | ||
swiftFrontend | ||
swiftSILGen | ||
swiftSILOptimizer | ||
swiftSerialization | ||
swiftClangImporter | ||
LLVM_COMPONENT_DEPENDS | ||
DebugInfoCodeView | ||
SWIFT_COMPONENT tools | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//===--- SILPassPipelineDumper.cpp ----------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2016 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// \file | ||
/// | ||
/// This is a simple tool that dumps out a yaml description of one of the | ||
/// current list of pass pipelines. Meant to be used to script on top of | ||
/// sil-opt. | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "swift/Basic/LLVM.h" | ||
#include "swift/Basic/LLVMInitialize.h" | ||
#include "swift/SILOptimizer/PassManager/PassPipeline.h" | ||
#include "llvm/Support/CommandLine.h" | ||
|
||
using namespace swift; | ||
|
||
static llvm::cl::opt<PassPipelineKind> | ||
PipelineKind(llvm::cl::desc("<pipeline kind>"), llvm::cl::values( | ||
#define PASSPIPELINE(NAME, DESCRIPTION) \ | ||
clEnumValN(PassPipelineKind::NAME, #NAME, DESCRIPTION), | ||
#include "swift/SILOptimizer/PassManager/PassPipeline.def" | ||
clEnumValEnd)); | ||
|
||
namespace llvm { | ||
llvm::raw_ostream &operator<<(llvm::raw_ostream &os, PassPipelineKind Kind) { | ||
switch (Kind) { | ||
#define PASSPIPELINE(NAME, DESCRIPTION) \ | ||
case PassPipelineKind::NAME: \ | ||
return os << #NAME; | ||
#include "swift/SILOptimizer/PassManager/PassPipeline.def" | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
INITIALIZE_LLVM(argc, argv); | ||
|
||
llvm::cl::ParseCommandLineOptions(argc, argv, | ||
"Swift SIL Pass Pipeline Dumper\n"); | ||
|
||
// TODO: add options to manipulate this. | ||
SILOptions Opt; | ||
|
||
switch (PipelineKind) { | ||
#define PASSPIPELINE(NAME, DESCRIPTION) \ | ||
case PassPipelineKind::NAME: { \ | ||
SILPassPipelinePlan::get##NAME##PassPipeline().print(llvm::outs()); \ | ||
break; \ | ||
} | ||
#define PASSPIPELINE_WITH_OPTIONS(NAME, DESCRIPTION) \ | ||
case PassPipelineKind::NAME: { \ | ||
SILPassPipelinePlan::get##NAME##PassPipeline(Opt).print(llvm::outs()); \ | ||
break; \ | ||
} | ||
#include "swift/SILOptimizer/PassManager/PassPipeline.def" | ||
} | ||
|
||
llvm::outs() << '\n'; | ||
|
||
return 0; | ||
}; |