diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-01-30 23:22:39 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-01-30 23:22:39 +0000 | 
| commit | ad84a730ba64ee4343e689f1695fdcbfb71fd7cb (patch) | |
| tree | 757ebfdeb42655ed235fb6521a81e23f1bc1c85e /llvm/lib/Transforms/Utils | |
| parent | a94523df7b4fbf63d6dbf7e0e60b29094d7f355f (diff) | |
| download | bcm5719-llvm-ad84a730ba64ee4343e689f1695fdcbfb71fd7cb.tar.gz bcm5719-llvm-ad84a730ba64ee4343e689f1695fdcbfb71fd7cb.zip | |
The inliner/cloner can now optionally take TargetData info, which can be
used by constant folding.
llvm-svn: 33676
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 12 | 
2 files changed, 14 insertions, 11 deletions
| diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index f47bf1b7bff..12dff3bf588 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -158,15 +158,17 @@ namespace {      std::vector<ReturnInst*> &Returns;      const char *NameSuffix;      ClonedCodeInfo *CodeInfo; +    const TargetData *TD;    public:      PruningFunctionCloner(Function *newFunc, const Function *oldFunc,                            std::map<const Value*, Value*> &valueMap,                            std::vector<ReturnInst*> &returns,                            const char *nameSuffix,  -                          ClonedCodeInfo *codeInfo) +                          ClonedCodeInfo *codeInfo, +                          const TargetData *td)      : NewFunc(newFunc), OldFunc(oldFunc), ValueMap(valueMap), Returns(returns), -      NameSuffix(nameSuffix), CodeInfo(codeInfo) { +      NameSuffix(nameSuffix), CodeInfo(codeInfo), TD(td) {      }      /// CloneBlock - The specified block is found to be reachable, clone it and @@ -290,7 +292,7 @@ ConstantFoldMappedInstruction(const Instruction *I) {      else        return 0;  // All operands not constant! -  return ConstantFoldInstOperands(I, &Ops[0], Ops.size()); +  return ConstantFoldInstOperands(I, &Ops[0], Ops.size(), TD);  }  /// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto, @@ -304,7 +306,8 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,                                       std::map<const Value*, Value*> &ValueMap,                                       std::vector<ReturnInst*> &Returns,                                       const char *NameSuffix,  -                                     ClonedCodeInfo *CodeInfo) { +                                     ClonedCodeInfo *CodeInfo, +                                     const TargetData *TD) {    assert(NameSuffix && "NameSuffix cannot be null!");  #ifndef NDEBUG @@ -314,7 +317,7 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,  #endif    PruningFunctionCloner PFC(NewFunc, OldFunc, ValueMap, Returns,  -                            NameSuffix, CodeInfo); +                            NameSuffix, CodeInfo, TD);    // Clone the entry block, and anything recursively reachable from it.    PFC.CloneBlock(&OldFunc->getEntryBlock()); diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index f4b1331c0f7..911bfe0a39a 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -22,11 +22,11 @@  #include "llvm/Support/CallSite.h"  using namespace llvm; -bool llvm::InlineFunction(CallInst *CI, CallGraph *CG) { -  return InlineFunction(CallSite(CI), CG); +bool llvm::InlineFunction(CallInst *CI, CallGraph *CG, const TargetData *TD) { +  return InlineFunction(CallSite(CI), CG, TD);  } -bool llvm::InlineFunction(InvokeInst *II, CallGraph *CG) { -  return InlineFunction(CallSite(II), CG); +bool llvm::InlineFunction(InvokeInst *II, CallGraph *CG, const TargetData *TD) { +  return InlineFunction(CallSite(II), CG, TD);  }  /// HandleInlinedInvoke - If we inlined an invoke site, we need to convert calls @@ -177,7 +177,7 @@ static void UpdateCallGraphAfterInlining(const Function *Caller,  // exists in the instruction stream.  Similiarly this will inline a recursive  // function by one level.  // -bool llvm::InlineFunction(CallSite CS, CallGraph *CG) { +bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {    Instruction *TheCall = CS.getInstruction();    assert(TheCall->getParent() && TheCall->getParent()->getParent() &&           "Instruction not in function!"); @@ -225,7 +225,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG) {      // (which can happen, e.g., because an argument was constant), but we'll be      // happy with whatever the cloner can do.      CloneAndPruneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i", -                              &InlinedFunctionInfo); +                              &InlinedFunctionInfo, TD);      // Remember the first block that is newly cloned over.      FirstNewBlock = LastBlock; ++FirstNewBlock; | 

