LLVM
15.0.0git
|
#include "llvm/Transforms/Scalar/ConstraintElimination.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ConstraintSystem.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/Scalar.h"
#include <string>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "constraint-elimination" |
Functions | |
STATISTIC (NumCondsRemoved, "Number of instructions removed") | |
DEBUG_COUNTER (EliminatedCounter, "conds-eliminated", "Controls which conditions are eliminated") | |
static SmallVector< std::pair< int64_t, Value * >, 4 > | decompose (Value *V, SmallVector< PreconditionTy, 4 > &Preconditions, bool IsSigned) |
static ConstraintTy | getConstraint (CmpInst::Predicate Pred, Value *Op0, Value *Op1, const DenseMap< Value *, unsigned > &Value2Index, DenseMap< Value *, unsigned > &NewIndices) |
Turn a condition CmpI into a vector of constraints, using indices from Value2Index . More... | |
static ConstraintTy | getConstraint (CmpInst *Cmp, ConstraintInfo &Info, DenseMap< Value *, unsigned > &NewIndices) |
static void | dumpWithNames (ConstraintTy &C, DenseMap< Value *, unsigned > &Value2Index) |
static void | tryToSimplifyOverflowMath (IntrinsicInst *II, ConstraintInfo &Info, SmallVectorImpl< Instruction * > &ToRemove) |
static bool | eliminateConstraints (Function &F, DominatorTree &DT) |
INITIALIZE_PASS_BEGIN (ConstraintElimination, "constraint-elimination", "Constraint Elimination", false, false) INITIALIZE_PASS_END(ConstraintElimination | |
Variables | |
static int64_t | MaxConstraintValue = std::numeric_limits<int64_t>::max() |
static int64_t | MinSignedConstraintValue = std::numeric_limits<int64_t>::min() |
constraint | elimination |
constraint Constraint | Elimination |
constraint Constraint | false |
#define DEBUG_TYPE "constraint-elimination" |
Definition at line 39 of file ConstraintElimination.cpp.
DEBUG_COUNTER | ( | EliminatedCounter | , |
"conds-eliminated" | , | ||
"Controls which conditions are eliminated" | |||
) |
|
static |
Definition at line 144 of file ConstraintElimination.cpp.
References llvm::SmallVectorImpl< T >::emplace_back(), GEP, llvm::ConstantInt::get(), llvm::ConstantInt::getSExtValue(), llvm::Value::getType(), llvm::ConstantInt::getZExtValue(), llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_UGE, llvm::ConstantInt::isNegative(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_NSWAdd(), llvm::PatternMatch::m_NUWAdd(), llvm::PatternMatch::m_NUWShl(), llvm::PatternMatch::m_NUWSub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), MaxConstraintValue, MinSignedConstraintValue, llvm::APInt::sgt(), llvm::APInt::slt(), and llvm::ConstantInt::uge().
Referenced by getConstraint().
Definition at line 434 of file ConstraintElimination.cpp.
References llvm::ConstraintSystem::addVariableRowFill(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size().
Referenced by eliminateConstraints().
|
static |
Definition at line 570 of file ConstraintElimination.cpp.
References assert(), B, BB, llvm::count_if(), llvm::dbgs(), dumpWithNames(), E, llvm::SmallVectorImpl< T >::emplace_back(), F, getConstraint(), llvm::ConstantInt::getFalse(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::ConstantInt::getTrue(), I, Info, llvm::CmpInst::isSigned(), LLVM_DEBUG, llvm::make_early_inc_range(), llvm::make_scope_exit(), llvm::ConstraintSystem::negate(), llvm::reverse(), S, llvm::DebugCounter::shouldExecute(), llvm::sort(), ToRemove, tryToSimplifyOverflowMath(), and llvm::DominatorTreeBase< NodeT, IsPostDom >::updateDFSNumbers().
Referenced by llvm::ConstraintEliminationPass::run().
|
static |
Definition at line 345 of file ConstraintElimination.cpp.
References getConstraint(), Info, and llvm::CmpInst::isSigned().
|
static |
Turn a condition CmpI
into a vector of constraints, using indices from Value2Index
.
Additional indices for newly discovered values are added to NewIndices
.
Definition at line 246 of file ConstraintElimination.cpp.
References decompose(), llvm::drop_begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, Insert, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::CmpInst::isSigned(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size(), llvm::Value::stripPointerCastsSameRepresentation(), and std::swap().
Referenced by eliminateConstraints(), getConstraint(), and tryToSimplifyOverflowMath().
INITIALIZE_PASS_BEGIN | ( | ConstraintElimination | , |
"constraint-elimination" | , | ||
"Constraint Elimination" | , | ||
false | , | ||
false | |||
) |
STATISTIC | ( | NumCondsRemoved | , |
"Number of instructions removed" | |||
) |
|
static |
Definition at line 522 of file ConstraintElimination.cpp.
References B, Builder, llvm::Instruction::eraseFromParent(), llvm::ConstantInt::get(), llvm::PoisonValue::get(), llvm::CallBase::getArgOperand(), getConstraint(), llvm::IntrinsicInst::getIntrinsicID(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getParent(), llvm::Value::getType(), I, llvm::CmpInst::ICMP_SGE, Info, llvm::CmpInst::isSigned(), llvm::PatternMatch::m_Value(), llvm::make_early_inc_range(), llvm::PatternMatch::match(), ToRemove, llvm::Value::use_empty(), and llvm::Value::users().
Referenced by eliminateConstraints().
constraint elimination |
Definition at line 806 of file ConstraintElimination.cpp.
constraint Constraint Elimination |
Definition at line 807 of file ConstraintElimination.cpp.
constraint Constraint false |
Definition at line 807 of file ConstraintElimination.cpp.
|
static |
Definition at line 45 of file ConstraintElimination.cpp.
Referenced by decompose().
|
static |
Definition at line 46 of file ConstraintElimination.cpp.
Referenced by decompose().