LLVM API Documentation
#include "InstCombine.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
Go to the source code of this file.
Functions | |
STATISTIC (NumDeadStore,"Number of dead stores eliminated") | |
STATISTIC (NumGlobalCopies,"Number of allocas copied from constant global") | |
static bool | pointsToConstantGlobal (Value *V) |
static bool | isOnlyCopiedFromConstantGlobal (Value *V, MemTransferInst *&TheCopy, SmallVectorImpl< Instruction * > &ToDelete, bool IsOffset=false) |
static MemTransferInst * | isOnlyCopiedFromConstantGlobal (AllocaInst *AI, SmallVectorImpl< Instruction * > &ToDelete) |
static Instruction * | InstCombineLoadCast (InstCombiner &IC, LoadInst &LI, const DataLayout *TD) |
InstCombineLoadCast - Fold 'load (cast P)' -> cast (load P)' when possible. More... | |
static Instruction * | InstCombineStoreToCast (InstCombiner &IC, StoreInst &SI) |
static bool | equivalentAddressValues (Value *A, Value *B) |
equivalentAddressValues - Test if A and B will obviously have the same value. This includes recognizing that t0 and t1 will have the same value in code like this: t0 = getelementptr @a, 0, 3 store i32 0, i32* t0 t1 = getelementptr @a, 0, 3 t2 = load i32* t1
Definition at line 545 of file InstCombineLoadStoreAlloca.cpp.
Referenced by llvm::InstCombiner::visitStoreInst().
|
static |
InstCombineLoadCast - Fold 'load (cast P)' -> cast (load P)' when possible.
Definition at line 283 of file InstCombineLoadStoreAlloca.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilder< preserveNames, T, Inserter >::CreateLoad(), llvm::PointerType::getAddressSpace(), llvm::LoadInst::getAlignment(), llvm::InstCombiner::getDataLayout(), llvm::SequentialType::getElementType(), llvm::ConstantExpr::getGetElementPtr(), llvm::Type::getInt64Ty(), llvm::DataLayout::getIntPtrType(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::LoadInst::getOrdering(), llvm::LoadInst::getSynchScope(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::Type::isPtrOrPtrVectorTy(), llvm::Type::isVectorTy(), llvm::LoadInst::isVolatile(), llvm::LoadInst::setAlignment(), and llvm::LoadInst::setAtomic().
Referenced by llvm::InstCombiner::visitLoadInst().
|
static |
InstCombineStoreToCast - Fold store V, (cast P) -> store (cast V), P when possible. This makes it generally easy to do alias analysis and/or SROA/mem2reg of the memory object.
NewGEPIndices - If SrcPTy is an aggregate type, we can emit a "noop gep" to its first element. This allows us to handle things like: store i32 xxx, (bitcast {foo*, float}* P to i32*) on 32-bit hosts.
Definition at line 453 of file InstCombineLoadStoreAlloca.cpp.
References llvm::InstCombiner::Builder, llvm::IRBuilder< preserveNames, T, Inserter >::CreateCast(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateInBoundsGEP(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::PointerType::get(), llvm::PointerType::getAddressSpace(), llvm::Value::getContext(), llvm::InstCombiner::getDataLayout(), llvm::SequentialType::getElementType(), llvm::Type::getInt32Ty(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::User::getOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::Type::isArrayTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::Type::isStructTy(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::User::setOperand().
Referenced by llvm::InstCombiner::visitStoreInst().
|
static |
isOnlyCopiedFromConstantGlobal - Recursively walk the uses of a (derived) pointer to an alloca. Ignore any reads of the pointer, return false if we see any stores or other unknown uses. If we see pointer arithmetic, keep track of whether it moves the pointer (with IsOffset) but otherwise traverse the uses. If we see a memcpy/memmove that targets an unoffseted pointer to the alloca, and if the source pointer is a pointer to a constant global, we can optimize this.
Definition at line 47 of file InstCombineLoadStoreAlloca.cpp.
References llvm::dyn_cast(), llvm::MemTransferInst::getSource(), llvm::MemIntrinsic::isVolatile(), LI, llvm::Intrinsic::lifetime_end, llvm::Intrinsic::lifetime_start, llvm::A64CC::MI, pointsToConstantGlobal(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::Value::use_begin(), and llvm::Value::use_end().
Referenced by isOnlyCopiedFromConstantGlobal(), and llvm::InstCombiner::visitAllocaInst().
|
static |
isOnlyCopiedFromConstantGlobal - Return true if the specified alloca is only modified by a copy from a constant global. If we can prove this, we can replace any uses of the alloca with uses of the global directly.
Definition at line 145 of file InstCombineLoadStoreAlloca.cpp.
References isOnlyCopiedFromConstantGlobal().
pointsToConstantGlobal - Return true if V (possibly indirectly) points to some part of a constant global variable. This intentionally only accepts constant expressions because we can't rewrite arbitrary instructions.
Definition at line 29 of file InstCombineLoadStoreAlloca.cpp.
Referenced by isOnlyCopiedFromConstantGlobal().
STATISTIC | ( | NumDeadStore | , |
"Number of dead stores eliminated" | |||
) |
STATISTIC | ( | NumGlobalCopies | , |
"Number of allocas copied from constant global" | |||
) |