LLVM  16.0.0git
Macros | Functions | Variables
ConstraintElimination.cpp File Reference
#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/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.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 <cmath>
#include <string>
Include dependency graph for ConstraintElimination.cpp:

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 int64_t multiplyWithOverflow (int64_t A, int64_t B)
 
static int64_t addWithOverflow (int64_t A, int64_t B)
 
static Decomposition decompose (Value *V, SmallVectorImpl< PreconditionTy > &Preconditions, bool IsSigned, const DataLayout &DL)
 
static bool canUseSExt (ConstantInt *CI)
 
static Decomposition decomposeGEP (GetElementPtrInst &GEP, SmallVectorImpl< PreconditionTy > &Preconditions, bool IsSigned, const DataLayout &DL)
 
static void dumpWithNames (const ConstraintSystem &CS, DenseMap< Value *, unsigned > &Value2Index)
 
static void dumpWithNames (ArrayRef< int64_t > C, DenseMap< Value *, unsigned > &Value2Index)
 
static bool checkAndReplaceCondition (CmpInst *Cmp, ConstraintInfo &Info)
 
static bool replaceSubOverflowUses (IntrinsicInst *II, Value *A, Value *B, SmallVectorImpl< Instruction * > &ToRemove)
 
static bool 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
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "constraint-elimination"

Definition at line 42 of file ConstraintElimination.cpp.

Function Documentation

◆ addWithOverflow()

static int64_t addWithOverflow ( int64_t  A,
int64_t  B 
)
static

Definition at line 59 of file ConstraintElimination.cpp.

References llvm::AddOverflow(), and B.

◆ canUseSExt()

static bool canUseSExt ( ConstantInt CI)
static

◆ checkAndReplaceCondition()

static bool checkAndReplaceCondition ( CmpInst Cmp,
ConstraintInfo &  Info 
)
static

◆ DEBUG_COUNTER()

DEBUG_COUNTER ( EliminatedCounter  ,
"conds-eliminated"  ,
"Controls which conditions are eliminated"   
)

◆ decompose()

static Decomposition decompose ( Value V,
SmallVectorImpl< PreconditionTy > &  Preconditions,
bool  IsSigned,
const DataLayout DL 
)
static

◆ decomposeGEP()

static Decomposition decomposeGEP ( GetElementPtrInst GEP,
SmallVectorImpl< PreconditionTy > &  Preconditions,
bool  IsSigned,
const DataLayout DL 
)
static

◆ dumpWithNames() [1/2]

static void dumpWithNames ( ArrayRef< int64_t >  C,
DenseMap< Value *, unsigned > &  Value2Index 
)
static

◆ dumpWithNames() [2/2]

static void dumpWithNames ( const ConstraintSystem CS,
DenseMap< Value *, unsigned > &  Value2Index 
)
static

◆ eliminateConstraints()

static bool eliminateConstraints ( Function F,
DominatorTree DT 
)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( ConstraintElimination  ,
"constraint-elimination ,
"Constraint Elimination ,
false  ,
false   
)

◆ multiplyWithOverflow()

static int64_t multiplyWithOverflow ( int64_t  A,
int64_t  B 
)
static

Definition at line 52 of file ConstraintElimination.cpp.

References B, and llvm::MulOverflow().

Referenced by decomposeGEP().

◆ replaceSubOverflowUses()

static bool replaceSubOverflowUses ( IntrinsicInst II,
Value A,
Value B,
SmallVectorImpl< Instruction * > &  ToRemove 
)
static

◆ STATISTIC()

STATISTIC ( NumCondsRemoved  ,
"Number of instructions removed  
)

◆ tryToSimplifyOverflowMath()

static bool tryToSimplifyOverflowMath ( IntrinsicInst II,
ConstraintInfo &  Info,
SmallVectorImpl< Instruction * > &  ToRemove 
)
static

Variable Documentation

◆ elimination

constraint elimination

Definition at line 1071 of file ConstraintElimination.cpp.

◆ Elimination

constraint Constraint Elimination

Definition at line 1072 of file ConstraintElimination.cpp.

◆ false

constraint Constraint false

Definition at line 1072 of file ConstraintElimination.cpp.

◆ MaxConstraintValue

int64_t MaxConstraintValue = std::numeric_limits<int64_t>::max()
static

Definition at line 48 of file ConstraintElimination.cpp.

Referenced by canUseSExt(), and decompose().

◆ MinSignedConstraintValue

int64_t MinSignedConstraintValue = std::numeric_limits<int64_t>::min()
static

Definition at line 49 of file ConstraintElimination.cpp.

Referenced by canUseSExt().