//===- JumpThreading.h - thread control through conditional BBs -*- 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 /// See the comments on JumpThreadingPass. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_SCALAR_JUMPTHREADING_H #define LLVM_TRANSFORMS_SCALAR_JUMPTHREADING_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/BlockFrequencyInfo.h" #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/Analysis/DomTreeUpdater.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include <optional> #include <utility> namespace llvm { class AAResults; class BasicBlock; class BinaryOperator; class BranchInst; class CmpInst; class Constant; class Function; class Instruction; class IntrinsicInst; class LazyValueInfo; class LoadInst; class PHINode; class SelectInst; class SwitchInst; class TargetLibraryInfo; class TargetTransformInfo; class Value; /// A private "module" namespace for types and utilities used by /// JumpThreading. /// These are implementation details and should not be used by clients. namespace jumpthreading { // These are at global scope so static functions can use them too. PredValueInfo; PredValueInfoTy; // This is used to keep track of what kind of constant we're currently hoping // to find. enum ConstantPreference { … }; } // end namespace jumpthreading /// This pass performs 'jump threading', which looks at blocks that have /// multiple predecessors and multiple successors. If one or more of the /// predecessors of the block can be proven to always jump to one of the /// successors, we forward the edge from the predecessor to the successor by /// duplicating the contents of this block. /// /// An example of when this can occur is code like this: /// /// if () { ... /// X = 4; /// } /// if (X < 3) { /// /// In this case, the unconditional branch at the end of the first if can be /// revectored to the false side of the second if. class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> { … }; } // end namespace llvm #endif // LLVM_TRANSFORMS_SCALAR_JUMPTHREADING_H