Files
swift-mirror/include/swift/SILOptimizer/Analysis/Analysis.def
Roman Levenstein f0a39e9e14 Add support for collecting various SIL optimizer counters
This patch implements collection and dumping of statistics about SILModules, SILFunctions and memory consumption during the execution of SIL optimization pipelines.

The following statistics can be collected:
  *  For SILFunctions: the number of SIL basic blocks, the number of SIL instructions, the number of SIL instructions of a specific kind, duration of a pass
  *  For SILModules: the number of SIL basic blocks, the number of SIL instructions, the number of SIL instructions of a specific kind, the number of SILFunctions, the amount of memory used by the compiler, duration of a pass

By default, any collection of statistics is disabled to avoid affecting compile times.

One can enable the collection of statistics and dumping of these statistics for the whole SILModule and/or for SILFunctions.

To reduce the amount of produced data, one can set thresholds in such a way that changes in the statistics are only reported if the delta between the old and the new values are at least X%. The deltas are computed as using the following formula:

   Delta = (NewValue - OldValue) / OldValue

Thresholds provide a simple way to perform a simple filtering of the collected statistics during the compilation. But if there is a need for a more complex analysis of collected data (e.g. aggregation by a pipeline stage or by the type of a transformation), it is often better to dump as much data as possible into a file using e.g. -sil-stats-dump-all -sil-stats-modules -sil-stats-functions and then e.g. use the helper scripts to store the collected data into a database and then perform complex queries on it. Many kinds of analysis can be then formulated pretty easily as SQL queries.
2017-09-10 21:47:55 -07:00

47 lines
1.5 KiB
C++

//===--- Analysis.def -------------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 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
//
//===----------------------------------------------------------------------===//
//
// This file allows for metaprogramming with Analyses. By adding an analysis
// name here, one is assured that all places in the compiler that the analysis
// will have a kind created for it and that the analysis will be registered in
// all locations where analyses are registered.
//
//===----------------------------------------------------------------------===//
/// ANALYSIS(NAME) This represents the name of an analysis. It is assumed that
/// the actual analysis is called `NAME ## ANALYSIS'.
#ifndef ANALYSIS
#define ANALYSIS(NAME)
#endif
ANALYSIS(AccessSummary)
ANALYSIS(Alias)
ANALYSIS(BasicCallee)
ANALYSIS(Caller)
ANALYSIS(ClassHierarchy)
ANALYSIS(ClosureScope)
ANALYSIS(Destructor)
ANALYSIS(Dominance)
ANALYSIS(EpilogueARC)
ANALYSIS(Escape)
ANALYSIS(InductionVariable)
ANALYSIS(Loop)
ANALYSIS(LoopRegion)
ANALYSIS(OptimizerStats)
ANALYSIS(PostDominance)
ANALYSIS(PostOrder)
ANALYSIS(RCIdentity)
ANALYSIS(SideEffect)
ANALYSIS(TypeExpansion)
#undef ANALYSIS