LLVM  14.0.0git
Macros | Functions | Variables
MemCpyOptimizer.cpp File Reference
#include "llvm/Transforms/Scalar/MemCpyOptimizer.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/None.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/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.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/PassManager.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.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 <utility>

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")
 
 STATISTIC (NumCallSlot, "Number of call slot optimizations performed")
 
 INITIALIZE_PASS_BEGIN (MemCpyOptLegacyPass, "memcpyopt", "MemCpy Optimization", false, false) INITIALIZE_PASS_END(MemCpyOptLegacyPass
 
MemCpy static false bool mayBeVisibleThroughUnwinding (Value *V, Instruction *Start, Instruction *End)
 
static bool accessedBetween (AliasAnalysis &AA, MemoryLocation Loc, const MemoryUseOrDef *Start, const MemoryUseOrDef *End)
 
static bool writtenBetween (MemorySSA *MSSA, MemoryLocation Loc, const MemoryUseOrDef *Start, const MemoryUseOrDef *End)
 
static bool hasUndefContents (Instruction *I, Value *Size)
 Determine whether the instruction has undefined content for the given Size, either because it was freshly alloca'd or started its lifetime. More...
 
static bool hasUndefContentsMSSA (MemorySSA *MSSA, AliasAnalysis *AA, Value *V, MemoryDef *Def, Value *Size)
 

Variables

static cl::opt< bool > EnableMemorySSA ("enable-memcpyopt-memoryssa", cl::init(true), cl::Hidden, cl::desc("Use MemorySSA-backed MemCpyOpt."))
 
 memcpyopt
 
MemCpy Optimization
 
MemCpy false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "memcpyopt"

Definition at line 68 of file MemCpyOptimizer.cpp.

Function Documentation

◆ accessedBetween()

static bool accessedBetween ( AliasAnalysis AA,
MemoryLocation  Loc,
const MemoryUseOrDef Start,
const MemoryUseOrDef End 
)
static

Definition at line 341 of file MemCpyOptimizer.cpp.

◆ hasUndefContents()

static bool hasUndefContents ( Instruction I,
Value Size 
)
static

Determine whether the instruction has undefined content for the given Size, either because it was freshly alloca'd or started its lifetime.

Definition at line 1251 of file MemCpyOptimizer.cpp.

References I, and llvm::Check::Size.

◆ hasUndefContentsMSSA()

static bool hasUndefContentsMSSA ( MemorySSA MSSA,
AliasAnalysis AA,
Value V,
MemoryDef Def,
Value Size 
)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( MemCpyOptLegacyPass  ,
"memcpyopt"  ,
"MemCpy Optimization ,
false  ,
false   
)

◆ mayBeVisibleThroughUnwinding()

MemCpy static false bool mayBeVisibleThroughUnwinding ( Value V,
Instruction Start,
Instruction End 
)
static

Definition at line 317 of file MemCpyOptimizer.cpp.

◆ STATISTIC() [1/5]

STATISTIC ( NumCallSlot  ,
"Number of call slot optimizations performed"   
)

◆ STATISTIC() [2/5]

STATISTIC ( NumCpyToSet  ,
"Number of memcpys converted to memset"   
)

◆ STATISTIC() [3/5]

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

◆ STATISTIC() [4/5]

STATISTIC ( NumMemSetInfer  ,
"Number of memsets inferred"   
)

◆ STATISTIC() [5/5]

STATISTIC ( NumMoveToCpy  ,
"Number of memmoves converted to memcpy  
)

◆ writtenBetween()

static bool writtenBetween ( MemorySSA MSSA,
MemoryLocation  Loc,
const MemoryUseOrDef Start,
const MemoryUseOrDef End 
)
static

Definition at line 356 of file MemCpyOptimizer.cpp.

Variable Documentation

◆ EnableMemorySSA

cl::opt<bool> EnableMemorySSA("enable-memcpyopt-memoryssa", cl::init(true), cl::Hidden, cl::desc("Use MemorySSA-backed MemCpyOpt."))
static

◆ false

MemCpy false

Definition at line 313 of file MemCpyOptimizer.cpp.

◆ memcpyopt

memcpyopt

Definition at line 312 of file MemCpyOptimizer.cpp.

◆ Optimization

MemCpy Optimization

Definition at line 312 of file MemCpyOptimizer.cpp.