15 #ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H
16 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
39 class TargetLibraryInfo;
40 class TargetTransformInfo;
44 template<
typename T>
class SmallVectorImpl;
58 const TargetLibraryInfo *TLI = 0);
74 const TargetLibraryInfo *TLI=0);
90 const TargetLibraryInfo *TLI = 0);
140 const DataLayout *
TD = 0);
161 bool VolatileLoads =
false,
162 Instruction *AllocaPoint = 0);
174 const DataLayout *
TD = 0);
186 template<
typename IRBuilderTy>
188 bool NoAssumptions =
false) {
195 bool isInBounds = GEPOp->
isInBounds() && !NoAssumptions;
198 unsigned IntPtrWidth = IntPtrTy->getScalarType()->getIntegerBitWidth();
199 uint64_t PtrSizeMask = ~0ULL >> (64 - IntPtrWidth);
206 if (
Constant *OpC = dyn_cast<Constant>(Op)) {
207 if (OpC->isZeroValue())
211 if (
StructType *STy = dyn_cast<StructType>(*GTI)) {
212 if (OpC->getType()->isVectorTy())
213 OpC = OpC->getSplatValue();
215 uint64_t OpValue = cast<ConstantInt>(OpC)->getZExtValue();
228 Result = Builder->CreateAdd(Result, Scale, GEP->
getName()+
".offs");
233 Op = Builder->CreateIntCast(Op, IntPtrTy,
true, Op->
getName()+
".c");
237 GEP->
getName()+
".idx", isInBounds );
241 Result = Builder->CreateAdd(Op, Result, GEP->
getName()+
".offs");
253 StoreInst *SI, DIBuilder &Builder);
258 LoadInst *
LI, DIBuilder &Builder);
bool FlattenCFG(BasicBlock *BB, AliasAnalysis *AA=0)
DbgDeclareInst * FindAllocaDbgDeclare(Value *V)
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=0)
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, Pass *P=0)
void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred, DataLayout *TD=0)
Value * EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &TD, User *GEP, bool NoAssumptions=false)
AllocaInst * DemoteRegToStack(Instruction &X, bool VolatileLoads=false, Instruction *AllocaPoint=0)
LoopInfoBase< BlockT, LoopT > * LI
static Constant * getNullValue(Type *Ty)
StringRef getName() const
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
const StructLayout * getStructLayout(StructType *Ty) const
bool replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress, DIBuilder &Builder)
bool RecursivelyDeleteDeadPHINode(PHINode *PN, const TargetLibraryInfo *TLI=0)
bool EliminateDuplicatePHINodes(BasicBlock *BB)
bool SimplifyInstructionsInBlock(BasicBlock *BB, const DataLayout *TD=0, const TargetLibraryInfo *TLI=0)
uint64_t getElementOffset(unsigned Idx) const
bool SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, const DataLayout *TD=0)
bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB)
LLVM Constant Representation.
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=0)
AllocaInst * DemotePHIToStack(PHINode *P, Instruction *AllocaPoint=0)
bool LowerDbgDeclare(Function &F)
bool FoldBranchToCommonDest(BranchInst *BI)
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
uint64_t getTypeAllocSize(Type *Ty) const
bool ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, StoreInst *SI, DIBuilder &Builder)
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=0)
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout *TD=0)
LLVM Value Representation.
bool removeUnreachableBlocks(Function &F)
Remove all blocks that can not be reached from the function's entry.
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD
static unsigned getKnownAlignment(Value *V, const DataLayout *TD=0)
getKnownAlignment - Try to infer an alignment for the specified pointer.
gep_type_iterator gep_type_begin(const User *GEP)