mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-02 00:36:36 +00:00
The inliner/cloner can now optionally take TargetData info, which can be
used by constant folding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33676 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3cab071f6f
commit
1dfdf8255e
@ -33,6 +33,7 @@ class ReturnInst;
|
||||
class CallSite;
|
||||
class Trace;
|
||||
class CallGraph;
|
||||
class TargetData;
|
||||
|
||||
/// CloneModule - Return an exact copy of the specified module
|
||||
///
|
||||
@ -141,7 +142,8 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
||||
std::map<const Value*, Value*> &ValueMap,
|
||||
std::vector<ReturnInst*> &Returns,
|
||||
const char *NameSuffix = "",
|
||||
ClonedCodeInfo *CodeInfo = 0);
|
||||
ClonedCodeInfo *CodeInfo = 0,
|
||||
const TargetData *TD = 0);
|
||||
|
||||
|
||||
/// CloneTraceInto - Clone T into NewFunc. Original<->clone mapping is
|
||||
@ -170,9 +172,9 @@ std::vector<BasicBlock *> CloneTrace(const std::vector<BasicBlock*> &origTrace);
|
||||
/// If a non-null callgraph pointer is provided, these functions update the
|
||||
/// CallGraph to represent the program after inlining.
|
||||
///
|
||||
bool InlineFunction(CallInst *C, CallGraph *CG = 0);
|
||||
bool InlineFunction(InvokeInst *II, CallGraph *CG = 0);
|
||||
bool InlineFunction(CallSite CS, CallGraph *CG = 0);
|
||||
bool InlineFunction(CallInst *C, CallGraph *CG = 0, const TargetData *TD = 0);
|
||||
bool InlineFunction(InvokeInst *II, CallGraph *CG = 0, const TargetData *TD =0);
|
||||
bool InlineFunction(CallSite CS, CallGraph *CG = 0, const TargetData *TD = 0);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user