mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-08 19:46:39 +00:00
simplify by using CallSite constructors; virtually eliminates CallSite::get from the tree
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109687 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
826c148aa5
commit
7d3056b160
@ -208,8 +208,8 @@ static bool AllCalleesPassInValidPointerForArgument(Argument *Arg) {
|
|||||||
// have direct callees.
|
// have direct callees.
|
||||||
for (Value::use_iterator UI = Callee->use_begin(), E = Callee->use_end();
|
for (Value::use_iterator UI = Callee->use_begin(), E = Callee->use_end();
|
||||||
UI != E; ++UI) {
|
UI != E; ++UI) {
|
||||||
CallSite CS = CallSite::get(*UI);
|
CallSite CS(*UI);
|
||||||
assert(CS.getInstruction() && "Should only have direct calls!");
|
assert(CS && "Should only have direct calls!");
|
||||||
|
|
||||||
if (!IsAlwaysValidPointer(CS.getArgument(ArgNo)))
|
if (!IsAlwaysValidPointer(CS.getArgument(ArgNo)))
|
||||||
return false;
|
return false;
|
||||||
@ -619,14 +619,13 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
|
|
||||||
// Get a new callgraph node for NF.
|
// Get a new callgraph node for NF.
|
||||||
CallGraphNode *NF_CGN = CG.getOrInsertFunction(NF);
|
CallGraphNode *NF_CGN = CG.getOrInsertFunction(NF);
|
||||||
|
|
||||||
|
|
||||||
// Loop over all of the callers of the function, transforming the call sites
|
// Loop over all of the callers of the function, transforming the call sites
|
||||||
// to pass in the loaded pointers.
|
// to pass in the loaded pointers.
|
||||||
//
|
//
|
||||||
SmallVector<Value*, 16> Args;
|
SmallVector<Value*, 16> Args;
|
||||||
while (!F->use_empty()) {
|
while (!F->use_empty()) {
|
||||||
CallSite CS = CallSite::get(F->use_back());
|
CallSite CS(F->use_back());
|
||||||
assert(CS.getCalledFunction() == F);
|
assert(CS.getCalledFunction() == F);
|
||||||
Instruction *Call = CS.getInstruction();
|
Instruction *Call = CS.getInstruction();
|
||||||
const AttrListPtr &CallPAL = CS.getAttributes();
|
const AttrListPtr &CallPAL = CS.getAttributes();
|
||||||
|
@ -220,11 +220,11 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
|||||||
//
|
//
|
||||||
std::vector<Value*> Args;
|
std::vector<Value*> Args;
|
||||||
while (!Fn.use_empty()) {
|
while (!Fn.use_empty()) {
|
||||||
CallSite CS = CallSite::get(Fn.use_back());
|
CallSite CS(Fn.use_back());
|
||||||
Instruction *Call = CS.getInstruction();
|
Instruction *Call = CS.getInstruction();
|
||||||
|
|
||||||
// Pass all the same arguments.
|
// Pass all the same arguments.
|
||||||
Args.assign(CS.arg_begin(), CS.arg_begin()+NumArgs);
|
Args.assign(CS.arg_begin(), CS.arg_begin() + NumArgs);
|
||||||
|
|
||||||
// Drop any attributes that were on the vararg arguments.
|
// Drop any attributes that were on the vararg arguments.
|
||||||
AttrListPtr PAL = CS.getAttributes();
|
AttrListPtr PAL = CS.getAttributes();
|
||||||
@ -724,7 +724,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
//
|
//
|
||||||
std::vector<Value*> Args;
|
std::vector<Value*> Args;
|
||||||
while (!F->use_empty()) {
|
while (!F->use_empty()) {
|
||||||
CallSite CS = CallSite::get(F->use_back());
|
CallSite CS(F->use_back());
|
||||||
Instruction *Call = CS.getInstruction();
|
Instruction *Call = CS.getInstruction();
|
||||||
|
|
||||||
AttributesVec.clear();
|
AttributesVec.clear();
|
||||||
|
@ -162,8 +162,8 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
|
|||||||
|
|
||||||
// Some instructions can be ignored even if they read or write memory.
|
// Some instructions can be ignored even if they read or write memory.
|
||||||
// Detect these now, skipping to the next instruction if one is found.
|
// Detect these now, skipping to the next instruction if one is found.
|
||||||
CallSite CS = CallSite::get(I);
|
CallSite CS(cast<Value>(I));
|
||||||
if (CS.getInstruction() && CS.getCalledFunction()) {
|
if (CS && CS.getCalledFunction()) {
|
||||||
// Ignore calls to functions in the same SCC.
|
// Ignore calls to functions in the same SCC.
|
||||||
if (SCCNodes.count(CS.getCalledFunction()))
|
if (SCCNodes.count(CS.getCalledFunction()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -94,7 +94,7 @@ bool IPCP::PropagateConstantsIntoArguments(Function &F) {
|
|||||||
if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
|
if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CallSite CS = CallSite::get(cast<Instruction>(U));
|
CallSite CS(cast<Instruction>(U));
|
||||||
if (!CS.isCallee(UI))
|
if (!CS.isCallee(UI))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ bool IPCP::PropagateConstantReturn(Function &F) {
|
|||||||
// constant.
|
// constant.
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E; ++UI) {
|
for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E; ++UI) {
|
||||||
CallSite CS = CallSite::get(*UI);
|
CallSite CS(*UI);
|
||||||
Instruction* Call = CS.getInstruction();
|
Instruction* Call = CS.getInstruction();
|
||||||
|
|
||||||
// Not a call instruction or a call instruction that's not calling F
|
// Not a call instruction or a call instruction that's not calling F
|
||||||
|
@ -238,11 +238,11 @@ bool Inliner::shouldInline(CallSite CS) {
|
|||||||
bool someOuterCallWouldNotBeInlined = false;
|
bool someOuterCallWouldNotBeInlined = false;
|
||||||
for (Value::use_iterator I = Caller->use_begin(), E =Caller->use_end();
|
for (Value::use_iterator I = Caller->use_begin(), E =Caller->use_end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
CallSite CS2 = CallSite::get(*I);
|
CallSite CS2(*I);
|
||||||
|
|
||||||
// If this isn't a call to Caller (it could be some other sort
|
// If this isn't a call to Caller (it could be some other sort
|
||||||
// of reference) skip it.
|
// of reference) skip it.
|
||||||
if (CS2.getInstruction() == 0 || CS2.getCalledFunction() != Caller)
|
if (!CS2 || CS2.getCalledFunction() != Caller)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
InlineCost IC2 = getInlineCost(CS2);
|
InlineCost IC2 = getInlineCost(CS2);
|
||||||
@ -334,10 +334,10 @@ bool Inliner::runOnSCC(CallGraphSCC &SCC) {
|
|||||||
|
|
||||||
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
|
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
|
||||||
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
|
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
|
||||||
CallSite CS = CallSite::get(I);
|
CallSite CS(cast<Value>(I));
|
||||||
// If this isn't a call, or it is a call to an intrinsic, it can
|
// If this isn't a call, or it is a call to an intrinsic, it can
|
||||||
// never be inlined.
|
// never be inlined.
|
||||||
if (CS.getInstruction() == 0 || isa<IntrinsicInst>(I))
|
if (!CS || isa<IntrinsicInst>(I))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If this is a direct call to an external function, we can never inline
|
// If this is a direct call to an external function, we can never inline
|
||||||
|
@ -156,7 +156,7 @@ bool SRETPromotion::isSafeToUpdateAllCallers(Function *F) {
|
|||||||
FnUseI != FnUseE; ++FnUseI) {
|
FnUseI != FnUseE; ++FnUseI) {
|
||||||
// The function is passed in as an argument to (possibly) another function,
|
// The function is passed in as an argument to (possibly) another function,
|
||||||
// we can't change it!
|
// we can't change it!
|
||||||
CallSite CS = CallSite::get(*FnUseI);
|
CallSite CS(*FnUseI);
|
||||||
Instruction *Call = CS.getInstruction();
|
Instruction *Call = CS.getInstruction();
|
||||||
// The function is used by something else than a call or invoke instruction,
|
// The function is used by something else than a call or invoke instruction,
|
||||||
// we can't change it!
|
// we can't change it!
|
||||||
@ -271,7 +271,7 @@ CallGraphNode *SRETPromotion::updateCallSites(Function *F, Function *NF) {
|
|||||||
CallGraphNode *NF_CGN = CG.getOrInsertFunction(NF);
|
CallGraphNode *NF_CGN = CG.getOrInsertFunction(NF);
|
||||||
|
|
||||||
while (!F->use_empty()) {
|
while (!F->use_empty()) {
|
||||||
CallSite CS = CallSite::get(*F->use_begin());
|
CallSite CS(*F->use_begin());
|
||||||
Instruction *Call = CS.getInstruction();
|
Instruction *Call = CS.getInstruction();
|
||||||
|
|
||||||
const AttrListPtr &PAL = F->getAttributes();
|
const AttrListPtr &PAL = F->getAttributes();
|
||||||
|
@ -508,7 +508,7 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) {
|
|||||||
// because we'll need to do type comparisons based on the underlying type.
|
// because we'll need to do type comparisons based on the underlying type.
|
||||||
Value *cpyDest = cpy->getDest();
|
Value *cpyDest = cpy->getDest();
|
||||||
Value *cpySrc = cpy->getSource();
|
Value *cpySrc = cpy->getSource();
|
||||||
CallSite CS = CallSite::get(C);
|
CallSite CS(C);
|
||||||
|
|
||||||
// We need to be able to reason about the size of the memcpy, so we require
|
// We need to be able to reason about the size of the memcpy, so we require
|
||||||
// that it be a constant.
|
// that it be a constant.
|
||||||
@ -636,10 +636,11 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// processMemCpy - perform simplication of memcpy's. If we have memcpy A which
|
/// processMemCpy - perform simplification of memcpy's. If we have memcpy A
|
||||||
/// copies X to Y, and memcpy B which copies Y to Z, then we can rewrite B to be
|
/// which copies X to Y, and memcpy B which copies Y to Z, then we can rewrite
|
||||||
/// a memcpy from X to Z (or potentially a memmove, depending on circumstances).
|
/// B to be a memcpy from X to Z (or potentially a memmove, depending on
|
||||||
/// This allows later passes to remove the first memcpy altogether.
|
/// circumstances). This allows later passes to remove the first memcpy
|
||||||
|
/// altogether.
|
||||||
bool MemCpyOpt::processMemCpy(MemCpyInst *M) {
|
bool MemCpyOpt::processMemCpy(MemCpyInst *M) {
|
||||||
MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();
|
MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();
|
||||||
|
|
||||||
|
@ -508,10 +508,10 @@ private:
|
|||||||
void visitLoadInst (LoadInst &I);
|
void visitLoadInst (LoadInst &I);
|
||||||
void visitGetElementPtrInst(GetElementPtrInst &I);
|
void visitGetElementPtrInst(GetElementPtrInst &I);
|
||||||
void visitCallInst (CallInst &I) {
|
void visitCallInst (CallInst &I) {
|
||||||
visitCallSite(CallSite::get(&I));
|
visitCallSite(&I);
|
||||||
}
|
}
|
||||||
void visitInvokeInst (InvokeInst &II) {
|
void visitInvokeInst (InvokeInst &II) {
|
||||||
visitCallSite(CallSite::get(&II));
|
visitCallSite(&II);
|
||||||
visitTerminatorInst(II);
|
visitTerminatorInst(II);
|
||||||
}
|
}
|
||||||
void visitCallSite (CallSite CS);
|
void visitCallSite (CallSite CS);
|
||||||
|
@ -42,8 +42,8 @@ namespace {
|
|||||||
Instruction *User = dyn_cast<Instruction>(*UI);
|
Instruction *User = dyn_cast<Instruction>(*UI);
|
||||||
if (!User) continue;
|
if (!User) continue;
|
||||||
|
|
||||||
CallSite CS = CallSite::get(User);
|
CallSite CS(cast<Value>(User));
|
||||||
if (!CS.getInstruction()) continue;
|
if (!CS) continue;
|
||||||
|
|
||||||
for (CallSite::arg_iterator AI = CS.arg_begin(),
|
for (CallSite::arg_iterator AI = CS.arg_begin(),
|
||||||
E = CS.arg_end(); AI != E; ++AI) {
|
E = CS.arg_end(); AI != E; ++AI) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user