LLVM  5.0.0
Macros | Functions | Variables
MemCpyOptimizer.cpp File Reference
#include "llvm/Transforms/Scalar/MemCpyOptimizer.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
Include dependency graph for MemCpyOptimizer.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "memcpyopt"
 

Functions

 STATISTIC (NumMemCpyInstr,"Number of memcpy instructions deleted")
 
 STATISTIC (NumMemSetInfer,"Number of memsets inferred")
 
 STATISTIC (NumMoveToCpy,"Number of memmoves converted to memcpy")
 
 STATISTIC (NumCpyToSet,"Number of memcpys converted to memset")
 
static int64_t GetOffsetFromIndex (const GEPOperator *GEP, unsigned Idx, bool &VariableIdxFound, const DataLayout &DL)
 
static bool IsPointerOffset (Value *Ptr1, Value *Ptr2, int64_t &Offset, const DataLayout &DL)
 Return true if Ptr1 is provably equal to Ptr2 plus a constant offset, and return that constant offset. More...
 
 INITIALIZE_PASS_BEGIN (MemCpyOptLegacyPass,"memcpyopt","MemCpy Optimization", false, false) INITIALIZE_PASS_END(MemCpyOptLegacyPass
 
static unsigned findCommonAlignment (const DataLayout &DL, const StoreInst *SI, const LoadInst *LI)
 
static bool moveUp (AliasAnalysis &AA, StoreInst *SI, Instruction *P, const LoadInst *LI)
 

Variables

 memcpyopt
 
MemCpy Optimization
 
MemCpy false
 

Macro Definition Documentation

#define DEBUG_TYPE   "memcpyopt"

Definition at line 60 of file MemCpyOptimizer.cpp.

Function Documentation

static unsigned findCommonAlignment ( const DataLayout &  DL,
const StoreInst *  SI,
const LoadInst *  LI 
)
static
static int64_t GetOffsetFromIndex ( const GEPOperator *  GEP,
unsigned  Idx,
bool &  VariableIdxFound,
const DataLayout &  DL 
)
static
INITIALIZE_PASS_BEGIN ( MemCpyOptLegacyPass  ,
"memcpyopt"  ,
"MemCpy Optimization"  ,
false  ,
false   
)
static bool IsPointerOffset ( Value *  Ptr1,
Value *  Ptr2,
int64_t &  Offset,
const DataLayout &  DL 
)
static

Return true if Ptr1 is provably equal to Ptr2 plus a constant offset, and return that constant offset.

For example, Ptr1 might be &A[42], and Ptr2 might be &A[40]. In this case offset would be -8.

Definition at line 101 of file MemCpyOptimizer.cpp.

References llvm::dyn_cast(), llvm::User::getNumOperands(), GetOffsetFromIndex(), llvm::User::getOperand(), and llvm::Value::stripPointerCasts().

static bool moveUp ( AliasAnalysis &  AA,
StoreInst *  SI,
Instruction *  P,
const LoadInst *  LI 
)
static
STATISTIC ( NumMemCpyInstr  ,
"Number of memcpy instructions deleted"   
)
STATISTIC ( NumMemSetInfer  ,
"Number of memsets inferred"   
)
STATISTIC ( NumMoveToCpy  ,
"Number of memmoves converted to memcpy"   
)
STATISTIC ( NumCpyToSet  ,
"Number of memcpys converted to memset"   
)

Variable Documentation

MemCpy false

Definition at line 374 of file MemCpyOptimizer.cpp.

memcpyopt

Definition at line 374 of file MemCpyOptimizer.cpp.

MemCpy Optimization

Definition at line 374 of file MemCpyOptimizer.cpp.