//===- llvm/PassAnalysisSupport.h - Analysis Pass Support code --*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines stuff that is used to define and "use" Analysis Passes. // This file is automatically #included by Pass.h, so: // // NO .CPP FILES SHOULD INCLUDE THIS FILE DIRECTLY // // Instead, #include Pass.h // //===----------------------------------------------------------------------===// #if !defined(LLVM_PASS_H) || defined(LLVM_PASSANALYSISSUPPORT_H) #error "Do not include <PassAnalysisSupport.h>; include <Pass.h> instead" #endif #ifndef LLVM_PASSANALYSISSUPPORT_H #define LLVM_PASSANALYSISSUPPORT_H #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include <cassert> #include <tuple> #include <utility> #include <vector> namespace llvm { class Function; class Pass; class PMDataManager; class StringRef; //===----------------------------------------------------------------------===// /// Represent the analysis usage information of a pass. This tracks analyses /// that the pass REQUIRES (must be available when the pass runs), REQUIRES /// TRANSITIVE (must be available throughout the lifetime of the pass), and /// analyses that the pass PRESERVES (the pass does not invalidate the results /// of these analyses). This information is provided by a pass to the Pass /// infrastructure through the getAnalysisUsage virtual function. /// class AnalysisUsage { … }; //===----------------------------------------------------------------------===// /// AnalysisResolver - Simple interface used by Pass objects to pull all /// analysis information out of pass manager that is responsible to manage /// the pass. /// class AnalysisResolver { … }; /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to /// get analysis information that might be around, for example to update it. /// This is different than getAnalysis in that it can fail (if the analysis /// results haven't been computed), so should only be used if you can handle /// the case when the analysis is not available. This method is often used by /// transformation APIs to update analysis results for a pass automatically as /// the transform is performed. template<typename AnalysisType> AnalysisType *Pass::getAnalysisIfAvailable() const { … } /// getAnalysis<AnalysisType>() - This function is used by subclasses to get /// to the analysis information that they claim to use by overriding the /// getAnalysisUsage function. template<typename AnalysisType> AnalysisType &Pass::getAnalysis() const { … } template<typename AnalysisType> AnalysisType &Pass::getAnalysisID(AnalysisID PI) const { … } /// getAnalysis<AnalysisType>() - This function is used by subclasses to get /// to the analysis information that they claim to use by overriding the /// getAnalysisUsage function. If as part of the dependencies, an IR /// transformation is triggered (e.g. because the analysis requires /// BreakCriticalEdges), and Changed is non null, *Changed is updated. template <typename AnalysisType> AnalysisType &Pass::getAnalysis(Function &F, bool *Changed) { … } template <typename AnalysisType> AnalysisType &Pass::getAnalysisID(AnalysisID PI, Function &F, bool *Changed) { … } } // end namespace llvm #endif // LLVM_PASSANALYSISSUPPORT_H