diff options
Diffstat (limited to 'include/llvm/Transforms/Utils')
-rw-r--r-- | include/llvm/Transforms/Utils/BuildLibCalls.h | 2 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/Cloning.h | 45 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/SSAUpdater.h | 30 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/ValueMapper.h | 29 |
4 files changed, 54 insertions, 52 deletions
diff --git a/include/llvm/Transforms/Utils/BuildLibCalls.h b/include/llvm/Transforms/Utils/BuildLibCalls.h index 8e76f50bb21e..6df3469ec064 100644 --- a/include/llvm/Transforms/Utils/BuildLibCalls.h +++ b/include/llvm/Transforms/Utils/BuildLibCalls.h @@ -42,7 +42,7 @@ namespace llvm { /// EmitStrNCpy - Emit a call to the strncpy function to the builder, for the /// specified pointer arguments and length. Value *EmitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, - const TargetData *TD); + const TargetData *TD, StringRef Name = "strncpy"); /// EmitMemCpy - Emit a call to the memcpy function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h index 5f494fb50d39..22bdc99ac18d 100644 --- a/include/llvm/Transforms/Utils/Cloning.h +++ b/include/llvm/Transforms/Utils/Cloning.h @@ -19,7 +19,9 @@ #define LLVM_TRANSFORMS_UTILS_CLONING_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { @@ -40,7 +42,6 @@ class TargetData; class Loop; class LoopInfo; class AllocaInst; -template <typename T> class SmallVectorImpl; /// CloneModule - Return an exact copy of the specified module /// @@ -158,6 +159,33 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, const TargetData *TD = 0, Instruction *TheCall = 0); + +/// InlineFunctionInfo - This class captures the data input to the +/// InlineFunction call, and records the auxiliary results produced by it. +class InlineFunctionInfo { +public: + explicit InlineFunctionInfo(CallGraph *cg = 0, const TargetData *td = 0) + : CG(cg), TD(td) {} + + /// CG - If non-null, InlineFunction will update the callgraph to reflect the + /// changes it makes. + CallGraph *CG; + const TargetData *TD; + + /// StaticAllocas - InlineFunction fills this in with all static allocas that + /// get copied into the caller. + SmallVector<AllocaInst*, 4> StaticAllocas; + + /// InlinedCalls - InlineFunction fills this in with callsites that were + /// inlined from the callee. This is only filled in if CG is non-null. + SmallVector<WeakVH, 8> InlinedCalls; + + void reset() { + StaticAllocas.clear(); + InlinedCalls.clear(); + } +}; + /// InlineFunction - This function inlines the called function into the basic /// block of the caller. This returns false if it is not possible to inline /// this call. The program is still in a well defined state if this occurs @@ -168,18 +196,9 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, /// exists in the instruction stream. Similiarly this will inline a recursive /// function by one level. /// -/// If a non-null callgraph pointer is provided, these functions update the -/// CallGraph to represent the program after inlining. -/// -/// If StaticAllocas is non-null, InlineFunction populates it with all of the -/// static allocas that it inlines into the caller. -/// -bool InlineFunction(CallInst *C, CallGraph *CG = 0, const TargetData *TD = 0, - SmallVectorImpl<AllocaInst*> *StaticAllocas = 0); -bool InlineFunction(InvokeInst *II, CallGraph *CG = 0, const TargetData *TD = 0, - SmallVectorImpl<AllocaInst*> *StaticAllocas = 0); -bool InlineFunction(CallSite CS, CallGraph *CG = 0, const TargetData *TD = 0, - SmallVectorImpl<AllocaInst*> *StaticAllocas = 0); +bool InlineFunction(CallInst *C, InlineFunctionInfo &IFI); +bool InlineFunction(InvokeInst *II, InlineFunctionInfo &IFI); +bool InlineFunction(CallSite CS, InlineFunctionInfo &IFI); } // End llvm namespace diff --git a/include/llvm/Transforms/Utils/SSAUpdater.h b/include/llvm/Transforms/Utils/SSAUpdater.h index 927e156abfb5..5b77ed660fcb 100644 --- a/include/llvm/Transforms/Utils/SSAUpdater.h +++ b/include/llvm/Transforms/Utils/SSAUpdater.h @@ -21,28 +21,31 @@ namespace llvm { class PHINode; template<typename T> class SmallVectorImpl; + class BumpPtrAllocator; /// SSAUpdater - This class updates SSA form for a set of values defined in /// multiple blocks. This is used when code duplication or another unstructured /// transformation wants to rewrite a set of uses of one value with uses of a /// set of values. class SSAUpdater { +public: + class BBInfo; + typedef SmallVectorImpl<BBInfo*> BlockListTy; + +private: /// AvailableVals - This keeps track of which value to use on a per-block - /// basis. When we insert PHI nodes, we keep track of them here. We use - /// TrackingVH's for the value of the map because we RAUW PHI nodes when we - /// eliminate them, and want the TrackingVH's to track this. - //typedef DenseMap<BasicBlock*, TrackingVH<Value> > AvailableValsTy; + /// basis. When we insert PHI nodes, we keep track of them here. + //typedef DenseMap<BasicBlock*, Value*> AvailableValsTy; void *AV; /// PrototypeValue is an arbitrary representative value, which we derive names /// and a type for PHI nodes. Value *PrototypeValue; - /// IncomingPredInfo - We use this as scratch space when doing our recursive - /// walk. This should only be used in GetValueInBlockInternal, normally it - /// should be empty. - //std::vector<std::pair<BasicBlock*, TrackingVH<Value> > > IncomingPredInfo; - void *IPI; + /// BBMap - The GetValueAtEndOfBlock method maintains this mapping from + /// basic blocks to BBInfo structures. + /// typedef DenseMap<BasicBlock*, BBInfo*> BBMapTy; + void *BM; /// InsertedPHIs - If this is non-null, the SSAUpdater adds all PHI nodes that /// it creates to the vector. @@ -99,6 +102,15 @@ public: private: Value *GetValueAtEndOfBlockInternal(BasicBlock *BB); + void BuildBlockList(BasicBlock *BB, BlockListTy *BlockList, + BumpPtrAllocator *Allocator); + void FindDominators(BlockListTy *BlockList); + void FindPHIPlacement(BlockListTy *BlockList); + void FindAvailableVals(BlockListTy *BlockList); + void FindExistingPHI(BasicBlock *BB, BlockListTy *BlockList); + bool CheckIfPHIMatches(PHINode *PHI); + void RecordMatchingPHI(PHINode *PHI); + void operator=(const SSAUpdater&); // DO NOT IMPLEMENT SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT }; diff --git a/include/llvm/Transforms/Utils/ValueMapper.h b/include/llvm/Transforms/Utils/ValueMapper.h deleted file mode 100644 index ed3341364181..000000000000 --- a/include/llvm/Transforms/Utils/ValueMapper.h +++ /dev/null @@ -1,29 +0,0 @@ -//===- ValueMapper.h - Interface shared by lib/Transforms/Utils -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the MapValue interface which is used by various parts of -// the Transforms/Utils library to implement cloning and linking facilities. -// -//===----------------------------------------------------------------------===// - -#ifndef VALUEMAPPER_H -#define VALUEMAPPER_H - -#include "llvm/ADT/DenseMap.h" - -namespace llvm { - class Value; - class Instruction; - typedef DenseMap<const Value *, Value *> ValueMapTy; - - Value *MapValue(const Value *V, ValueMapTy &VM); - void RemapInstruction(Instruction *I, ValueMapTy &VM); -} // End llvm namespace - -#endif |