LLVM API Documentation

MemCpyOptimizer.cpp File Reference

#include "llvm/Transforms/Scalar.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Instructions.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Target/TargetData.h"
#include <list>

Include dependency graph for MemCpyOptimizer.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "memcpyopt"

Functions

 STATISTIC (NumMemCpyInstr,"Number of memcpy instructions deleted")
 STATISTIC (NumMemSetInfer,"Number of memsets inferred")
static Value * isBytewiseValue (Value *V)
static int64_t GetOffsetFromIndex (const GetElementPtrInst *GEP, unsigned Idx, bool &VariableIdxFound, TargetData &TD)
static bool IsPointerOffset (Value *Ptr1, Value *Ptr2, int64_t &Offset, TargetData &TD)
FunctionPass * llvm::createMemCpyOptPass ()

Variables

static RegisterPass< MemCpyOpt > X ("memcpyopt","MemCpy Optimization")


Define Documentation

#define DEBUG_TYPE   "memcpyopt"

Definition at line 15 of file MemCpyOptimizer.cpp.


Function Documentation

static int64_t GetOffsetFromIndex ( const GetElementPtrInst *  GEP,
unsigned  Idx,
bool &  VariableIdxFound,
TargetData &  TD 
) [static]

static Value* isBytewiseValue ( Value *  V  )  [static]

isBytewiseValue - If the specified value can be set by repeating the same byte in memory, return the i8 value that it is represented with. This is true for all i8 values obviously, but is also true for i32 0, i32 -1, i16 0xF0F0, double 0.0 etc. If the value can't be handled with a repeated byte store (e.g. i16 0x1234), return null.

Definition at line 38 of file MemCpyOptimizer.cpp.

References llvm::APInt::getBitWidth(), llvm::Value::getType(), llvm::isPowerOf2_32(), llvm::APInt::lshr(), llvm::APInt::trunc(), and Val.

static bool IsPointerOffset ( Value *  Ptr1,
Value *  Ptr2,
int64_t &  Offset,
TargetData &  TD 
) [static]

IsPointerOffset - 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 117 of file MemCpyOptimizer.cpp.

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

STATISTIC ( NumMemSetInfer  ,
"Number of memsets inferred"   
)

STATISTIC ( NumMemCpyInstr  ,
"Number of memcpy instructions deleted"   
)


Variable Documentation

int64_t End

char ID [static]

Definition at line 301 of file MemCpyOptimizer.cpp.

std::list<MemsetRange> Ranges

Ranges - A sorted list of the memset ranges. We use std::list here because each element is relatively large and expensive to copy.

Definition at line 211 of file MemCpyOptimizer.cpp.

int64_t Start

StartPtr - The getelementptr instruction that points to the start of the range.

Definition at line 163 of file MemCpyOptimizer.cpp.

Definition at line 213 of file MemCpyOptimizer.cpp.

TheStores - The actual stores that make up this range.

Definition at line 169 of file MemCpyOptimizer.cpp.

RegisterPass<MemCpyOpt> X("memcpyopt","MemCpy Optimization") [static]