LLVM API Documentation
#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>
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 DEBUG_TYPE "memcpyopt" |
Definition at line 15 of file MemCpyOptimizer.cpp.
| static int64_t GetOffsetFromIndex | ( | const GetElementPtrInst * | GEP, | |
| unsigned | Idx, | |||
| bool & | VariableIdxFound, | |||
| TargetData & | TD | |||
| ) | [static] |
Definition at line 84 of file MemCpyOptimizer.cpp.
References llvm::dyn_cast(), llvm::gep_type_begin(), llvm::StructLayout::getElementOffset(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::ConstantInt::getSExtValue(), llvm::TargetData::getStructLayout(), llvm::TargetData::getTypePaddedSize(), llvm::ConstantInt::getZExtValue(), llvm::ConstantInt::isZero(), and Offset.
Referenced by IsPointerOffset().
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" | ||||
| ) |
Alignment - The known alignment of the first store.
Definition at line 166 of file MemCpyOptimizer.cpp.
Referenced by CopyGVAttributes(), llvm::StringMapEntry< ValueTy >::Create(), ExpandConstantFP(), ExpandUnalignedLoad(), ExpandUnalignedStore(), llvm::X86InstrInfo::foldMemoryOperandImpl(), llvm::ConstantPoolSDNode::getAlignment(), llvm::MachineBasicBlock::getAlignment(), llvm::LiveInterval::getNextValue(), llvm::TargetData::getPreferredAlignment(), llvm::MachineFunction::MachineFunction(), llvm::MachineBasicBlock::print(), llvm::MachineBasicBlock::setAlignment(), and WriteAttributeTable().
| int64_t End |
Definition at line 159 of file MemCpyOptimizer.cpp.
Referenced by llvm::User::allocHungoffUses(), llvm::CloneTrace(), llvm::Archive::findModulesDefiningSymbols(), llvm::ProgramInfo::getSourceFile(), llvm::getToken(), llvm::TypeSymbolTable::getUniqueName(), llvm::Use::getUser(), llvm::Archive::loadArchive(), llvm::Archive::loadSymbolTable(), MarkIndicesSafe(), llvm::LiveInterval::MergeInClobberRanges(), llvm::LiveInterval::MergeValueInAsValue(), llvm::User::operator new(), and llvm::Archive::parseSymbolTable().
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 |
Definition at line 159 of file MemCpyOptimizer.cpp.
Referenced by llvm::ProgramInfo::getSourceFile(), llvm::getToken(), llvm::User::operator delete(), llvm::User::operator new(), and llvm::SCEVExpander::visitAddRecExpr().
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.
| SmallVector<StoreInst*, 16> TheStores |
TheStores - The actual stores that make up this range.
Definition at line 169 of file MemCpyOptimizer.cpp.
RegisterPass<MemCpyOpt> X("memcpyopt","MemCpy Optimization") [static] |