//===- GVN.h - Eliminate redundant values and loads -------------*- 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 // //===----------------------------------------------------------------------===// /// \file /// This file provides the interface for LLVM's Global Value Numbering pass /// which eliminates fully redundant instructions. It also does somewhat Ad-Hoc /// PRE and dead load elimination. /// //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_SCALAR_GVN_H #define LLVM_TRANSFORMS_SCALAR_GVN_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Compiler.h" #include <cstdint> #include <optional> #include <utility> #include <vector> namespace llvm { class AAResults; class AssumeInst; class AssumptionCache; class BasicBlock; class BranchInst; class CallInst; class ExtractValueInst; class Function; class FunctionPass; class GetElementPtrInst; class ImplicitControlFlowTracking; class LoadInst; class LoopInfo; class MemDepResult; class MemoryDependenceResults; class MemorySSA; class MemorySSAUpdater; class NonLocalDepResult; class OptimizationRemarkEmitter; class PHINode; class TargetLibraryInfo; class Value; /// A private "module" namespace for types and utilities used by GVN. These /// are implementation details and should not be used by clients. namespace LLVM_LIBRARY_VISIBILITY gvn { struct AvailableValue; struct AvailableValueInBlock; class GVNLegacyPass; } // end namespace gvn /// A set of parameters to control various transforms performed by GVN pass. // Each of the optional boolean parameters can be set to: /// true - enabling the transformation. /// false - disabling the transformation. /// None - relying on a global default. /// Intended use is to create a default object, modify parameters with /// additional setters and then pass it to GVN. struct GVNOptions { … }; /// The core GVN pass object. /// /// FIXME: We should have a good summary of the GVN algorithm implemented by /// this particular pass here. class GVNPass : public PassInfoMixin<GVNPass> { … }; /// Create a legacy GVN pass. This also allows parameterizing whether or not /// MemDep is enabled. FunctionPass *createGVNPass(bool NoMemDepAnalysis = false); /// A simple and fast domtree-based GVN pass to hoist common expressions /// from sibling branches. struct GVNHoistPass : PassInfoMixin<GVNHoistPass> { … }; /// Uses an "inverted" value numbering to decide the similarity of /// expressions and sinks similar expressions into successors. struct GVNSinkPass : PassInfoMixin<GVNSinkPass> { … }; } // end namespace llvm #endif // LLVM_TRANSFORMS_SCALAR_GVN_H