|
LLVM 22.0.0git
|
#include "llvm/Transforms/Scalar/MemCpyOptimizer.h"#include "llvm/ADT/DenseSet.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/ScopeExit.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/CFG.h"#include "llvm/Analysis/CaptureTracking.h"#include "llvm/Analysis/GlobalsModRef.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/Loads.h"#include "llvm/Analysis/MemoryLocation.h"#include "llvm/Analysis/MemorySSA.h"#include "llvm/Analysis/MemorySSAUpdater.h"#include "llvm/Analysis/PostDominators.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/Analysis/ValueTracking.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/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/PassManager.h"#include "llvm/IR/Type.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/Support/Casting.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Utils/Local.h"#include <algorithm>#include <cassert>#include <cstdint>#include <optional>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "memcpyopt" |
Functions | |
| STATISTIC (NumMemCpyInstr, "Number of memcpy instructions deleted") | |
| STATISTIC (NumMemMoveInstr, "Number of memmove 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") | |
| STATISTIC (NumStackMove, "Number of stack-move optimizations performed") | |
| static bool | overreadUndefContents (MemorySSA *MSSA, MemCpyInst *MemCpy, MemIntrinsic *MemSrc, BatchAAResults &BAA) |
| static bool | mayBeVisibleThroughUnwinding (Value *V, Instruction *Start, Instruction *End) |
| static bool | accessedBetween (BatchAAResults &AA, MemoryLocation Loc, const MemoryUseOrDef *Start, const MemoryUseOrDef *End, Instruction **SkippedLifetimeStart=nullptr) |
| static bool | writtenBetween (MemorySSA *MSSA, BatchAAResults &AA, MemoryLocation Loc, const MemoryUseOrDef *Start, const MemoryUseOrDef *End) |
| static bool | hasUndefContents (MemorySSA *MSSA, BatchAAResults &AA, Value *V, MemoryDef *Def) |
| Determine whether the pointer V had only undefined content (due to Def), either because it was freshly alloca'd or started its lifetime. | |
| static bool | isZeroSize (Value *Size) |
Variables | |
| static cl::opt< bool > | EnableMemCpyOptWithoutLibcalls ("enable-memcpyopt-without-libcalls", cl::Hidden, cl::desc("Enable memcpyopt even when libcalls are disabled")) |
| #define DEBUG_TYPE "memcpyopt" |
Definition at line 64 of file MemCpyOptimizer.cpp.
|
static |
Definition at line 298 of file MemCpyOptimizer.cpp.
References assert(), llvm::cast(), llvm::dyn_cast(), llvm::MemoryAccess::getBlock(), llvm::MemoryAccess::getIterator(), I, II, llvm::isModOrRefSet(), and llvm::make_range().
|
static |
Determine whether the pointer V had only undefined content (due to Def), either because it was freshly alloca'd or started its lifetime.
Definition at line 1388 of file MemCpyOptimizer.cpp.
References llvm::dyn_cast(), llvm::dyn_cast_or_null(), llvm::getUnderlyingObject(), II, llvm::isa(), and llvm::MemorySSA::isLiveOnEntryDef().
Referenced by overreadUndefContents().
Definition at line 1700 of file MemCpyOptimizer.cpp.
References llvm::CallingConv::C, llvm::dyn_cast(), I, llvm::isa(), llvm::simplifyInstruction(), and Size.
|
static |
Definition at line 268 of file MemCpyOptimizer.cpp.
References llvm::any_of(), assert(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::getUnderlyingObject(), I, llvm::isNotVisibleOnUnwind(), and llvm::make_range().
|
static |
Definition at line 1406 of file MemCpyOptimizer.cpp.
References llvm::dyn_cast(), llvm::MemorySSAWalker::getClobberingMemoryAccess(), llvm::MemoryUseOrDef::getDefiningAccess(), llvm::MemoryLocation::getForSource(), llvm::MemorySSA::getMemoryAccess(), llvm::MemTransferBase< BaseCL >::getSource(), llvm::MemorySSA::getWalker(), and hasUndefContents().
| STATISTIC | ( | NumCallSlot | , |
| "Number of call slot optimizations performed" | ) |
| STATISTIC | ( | NumCpyToSet | , |
| "Number of memcpys converted to memset" | ) |
| STATISTIC | ( | NumMemCpyInstr | , |
| "Number of memcpy instructions deleted" | ) |
| STATISTIC | ( | NumMemMoveInstr | , |
| "Number of memmove instructions deleted" | ) |
| STATISTIC | ( | NumMemSetInfer | , |
| "Number of memsets inferred" | ) |
| STATISTIC | ( | NumMoveToCpy | , |
| "Number of memmoves converted to memcpy" | ) |
| STATISTIC | ( | NumStackMove | , |
| "Number of stack-move optimizations performed" | ) |
References DL.
|
static |
Definition at line 322 of file MemCpyOptimizer.cpp.
References llvm::any_of(), llvm::MemorySSA::dominates(), llvm::MemoryAccess::getBlock(), llvm::MemorySSAWalker::getClobberingMemoryAccess(), llvm::MemoryUseOrDef::getDefiningAccess(), llvm::MemoryAccess::getIterator(), llvm::MemorySSA::getWalker(), llvm::isa(), and llvm::make_range().