|
LLVM
3.7.0
|
#include "llvm/Transforms/Scalar.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SetVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/CaptureTracking.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/MemoryDependenceAnalysis.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/Pass.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Utils/Local.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "dse" |
Enumerations | |
| enum | OverwriteResult |
Functions | |
| STATISTIC (NumFastStores,"Number of stores deleted") | |
| STATISTIC (NumFastOther,"Number of other instrs removed") | |
| static void | DeleteDeadInstruction (Instruction *I, MemoryDependenceAnalysis &MD, const TargetLibraryInfo *TLI, SmallSetVector< Value *, 16 > *ValueSet=nullptr) |
| DeleteDeadInstruction - Delete this instruction. More... | |
| static bool | hasMemoryWrite (Instruction *I, const TargetLibraryInfo *TLI) |
| hasMemoryWrite - Does this instruction write some memory? This only returns true for things that we can analyze with other helpers below. More... | |
| static MemoryLocation | getLocForWrite (Instruction *Inst, AliasAnalysis &AA) |
| getLocForWrite - Return a Location stored to by the specified instruction. More... | |
| static MemoryLocation | getLocForRead (Instruction *Inst, AliasAnalysis &AA) |
| getLocForRead - Return the location read by the specified "hasMemoryWrite" instruction if any. More... | |
| static bool | isRemovable (Instruction *I) |
| isRemovable - If the value of this instruction and the memory it writes to is unused, may we delete this instruction? More... | |
| static bool | isShortenable (Instruction *I) |
| isShortenable - Returns true if this instruction can be safely shortened in length. More... | |
| static Value * | getStoredPointerOperand (Instruction *I) |
| getStoredPointerOperand - Return the pointer that is being written to. More... | |
| static uint64_t | getPointerSize (const Value *V, const DataLayout &DL, const TargetLibraryInfo *TLI) |
| static OverwriteResult | isOverwrite (const MemoryLocation &Later, const MemoryLocation &Earlier, const DataLayout &DL, const TargetLibraryInfo *TLI, int64_t &EarlierOff, int64_t &LaterOff) |
| isOverwrite - Return 'OverwriteComplete' if a store to the 'Later' location completely overwrites a store to the 'Earlier' location. More... | |
| static bool | isPossibleSelfRead (Instruction *Inst, const MemoryLocation &InstStoreLoc, Instruction *DepWrite, AliasAnalysis &AA) |
| isPossibleSelfRead - If 'Inst' might be a self read (i.e. More... | |
| static void | FindUnconditionalPreds (SmallVectorImpl< BasicBlock * > &Blocks, BasicBlock *BB, DominatorTree *DT) |
| Find all blocks that will unconditionally lead to the block BB and append them to F. More... | |
| #define DEBUG_TYPE "dse" |
Definition at line 41 of file DeadStoreElimination.cpp.
| enum OverwriteResult |
Definition at line 324 of file DeadStoreElimination.cpp.
|
static |
DeleteDeadInstruction - Delete this instruction.
Before we do, go through and zero out all the operands of this instruction. If any of them become dead, delete them and the computation tree that feeds them.
If ValueSet is non-null, remove any deleted instructions from it as well.
Definition at line 116 of file DeadStoreElimination.cpp.
References llvm::SmallVectorBase::empty(), llvm::Instruction::eraseFromParent(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::isInstructionTriviallyDead(), op, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::iplist< NodeTy, Traits >::remove(), llvm::MemoryDependenceAnalysis::removeInstruction(), llvm::User::setOperand(), and llvm::Value::use_empty().
|
static |
Find all blocks that will unconditionally lead to the block BB and append them to F.
Definition at line 629 of file DeadStoreElimination.cpp.
References llvm::TerminatorInst::getNumSuccessors(), llvm::BasicBlock::getTerminator(), I, llvm::DominatorTree::isReachableFromEntry(), llvm::pred_begin(), llvm::pred_end(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
|
static |
getLocForRead - Return the location read by the specified "hasMemoryWrite" instruction if any.
Definition at line 227 of file DeadStoreElimination.cpp.
References llvm::MemoryLocation::getForSource(), llvm::AliasAnalysis::getTargetLibraryInfo(), and hasMemoryWrite().
Referenced by isPossibleSelfRead().
|
static |
getLocForWrite - Return a Location stored to by the specified instruction.
If isRemovable returns true, this function and getLocForRead completely describe the memory operations for this instruction.
Definition at line 197 of file DeadStoreElimination.cpp.
References llvm::dyn_cast(), llvm::MemoryLocation::get(), llvm::CallInst::getArgOperand(), llvm::MemoryLocation::getForDest(), llvm::IntrinsicInst::getIntrinsicID(), llvm::AArch64CC::MI, and SI.
|
static |
Definition at line 315 of file DeadStoreElimination.cpp.
References llvm::getObjectSize(), and llvm::MemoryLocation::UnknownSize.
Referenced by isOverwrite().
|
static |
getStoredPointerOperand - Return the pointer that is being written to.
Definition at line 295 of file DeadStoreElimination.cpp.
References llvm::CS, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getArgument(), llvm_unreachable, llvm::AArch64CC::MI, and SI.
|
static |
hasMemoryWrite - Does this instruction write some memory? This only returns true for things that we can analyze with other helpers below.
Definition at line 156 of file DeadStoreElimination.cpp.
References llvm::CS, llvm::Value::getName(), llvm::TargetLibraryInfo::getName(), and llvm::TargetLibraryInfo::has().
Referenced by getLocForRead().
|
static |
isOverwrite - Return 'OverwriteComplete' if a store to the 'Later' location completely overwrites a store to the 'Earlier' location.
'OverwriteEnd' if the end of the 'Earlier' location is completely overwritten by 'Later', or 'OverwriteUnknown' if nothing can be determined
Definition at line 336 of file DeadStoreElimination.cpp.
References llvm::GetPointerBaseWithConstantOffset(), getPointerSize(), llvm::GetUnderlyingObject(), llvm::MemoryLocation::Ptr, llvm::MemoryLocation::Size, llvm::Value::stripPointerCasts(), and llvm::MemoryLocation::UnknownSize.
|
static |
isPossibleSelfRead - If 'Inst' might be a self read (i.e.
a noop copy of a memory region into an identical pointer) then it doesn't actually make its input dead in the traditional sense. Consider this case:
memcpy(A <- B) memcpy(A <- A)
In this case, the second store to A does not make the first store to A dead. The usual situation isn't an explicit A<-A store like this (which can be trivially removed) but a case where two pointers may alias.
This function detects when it is unsafe to remove a dependent instruction because the DSE inducing instruction may be a self-read.
Definition at line 443 of file DeadStoreElimination.cpp.
References getLocForRead(), llvm::AliasAnalysis::isMustAlias(), llvm::AliasAnalysis::isNoAlias(), and llvm::MemoryLocation::Ptr.
|
static |
isRemovable - If the value of this instruction and the memory it writes to is unused, may we delete this instruction?
Definition at line 241 of file DeadStoreElimination.cpp.
References llvm::CS, isVolatile(), llvm_unreachable, and SI.
|
static |
isShortenable - Returns true if this instruction can be safely shortened in length.
Definition at line 274 of file DeadStoreElimination.cpp.
| STATISTIC | ( | NumFastStores | , |
| "Number of stores deleted" | |||
| ) |
| STATISTIC | ( | NumFastOther | , |
| "Number of other instrs removed" | |||
| ) |
1.8.6