//===- PhiValues.h - Phi Value Analysis -------------------------*- 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 the PhiValues class, and associated passes, which can be // used to find the underlying values of the phis in a function, i.e. the // non-phi values that can be found by traversing the phi graph. // // This information is computed lazily and cached. If new phis are added to the // function they are handled correctly, but if an existing phi has its operands // modified PhiValues has to be notified by calling invalidateValue. // //===----------------------------------------------------------------------===// #ifndef LLVM_ANALYSIS_PHIVALUES_H #define LLVM_ANALYSIS_PHIVALUES_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SetVector.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" namespace llvm { class Value; class PHINode; class Function; /// Class for calculating and caching the underlying values of phis in a /// function. /// /// Initially the PhiValues is empty, and gets incrementally populated whenever /// it is queried. class PhiValues { … }; /// The analysis pass which yields a PhiValues /// /// The analysis does nothing by itself, and just returns an empty PhiValues /// which will get filled in as it's used. class PhiValuesAnalysis : public AnalysisInfoMixin<PhiValuesAnalysis> { … }; /// A pass for printing the PhiValues for a function. /// /// This pass doesn't print whatever information the PhiValues happens to hold, /// but instead first uses the PhiValues to analyze all the phis in the function /// so the complete information is printed. class PhiValuesPrinterPass : public PassInfoMixin<PhiValuesPrinterPass> { … }; /// Wrapper pass for the legacy pass manager class PhiValuesWrapperPass : public FunctionPass { … }; } // namespace llvm #endif