//===- llvm/Analysis/AssumptionCache.h - Track @llvm.assume -----*- 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 contains a pass that keeps track of @llvm.assume intrinsics in // the functions of a module (allowing assumptions within any function to be // found cheaply by other parts of the optimizer). // //===----------------------------------------------------------------------===// #ifndef LLVM_ANALYSIS_ASSUMPTIONCACHE_H #define LLVM_ANALYSIS_ASSUMPTIONCACHE_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" #include <memory> namespace llvm { class AssumeInst; class Function; class raw_ostream; class TargetTransformInfo; class Value; /// A cache of \@llvm.assume calls within a function. /// /// This cache provides fast lookup of assumptions within a function by caching /// them and amortizing the cost of scanning for them across all queries. Passes /// that create new assumptions are required to call registerAssumption() to /// register any new \@llvm.assume calls that they create. Deletions of /// \@llvm.assume calls do not require special handling. class AssumptionCache { … }; /// A function analysis which provides an \c AssumptionCache. /// /// This analysis is intended for use with the new pass manager and will vend /// assumption caches for a given function. class AssumptionAnalysis : public AnalysisInfoMixin<AssumptionAnalysis> { … }; /// Printer pass for the \c AssumptionAnalysis results. class AssumptionPrinterPass : public PassInfoMixin<AssumptionPrinterPass> { … }; /// An immutable pass that tracks lazily created \c AssumptionCache /// objects. /// /// This is essentially a workaround for the legacy pass manager's weaknesses /// which associates each assumption cache with Function and clears it if the /// function is deleted. The nature of the AssumptionCache is that it is not /// invalidated by any changes to the function body and so this is sufficient /// to be conservatively correct. class AssumptionCacheTracker : public ImmutablePass { … }; template<> struct simplify_type<AssumptionCache::ResultElem> { … }; template<> struct simplify_type<const AssumptionCache::ResultElem> { … }; } // end namespace llvm #endif // LLVM_ANALYSIS_ASSUMPTIONCACHE_H