forked from OSchip/llvm-project
parent
9dbf3ee9d0
commit
10426b571e
|
@ -886,9 +886,9 @@ bool ObjCARCExpand::runOnFunction(Function &F) {
|
||||||
|
|
||||||
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
|
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
|
||||||
Instruction *Inst = &*I;
|
Instruction *Inst = &*I;
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCExpand: Visiting: " << *Inst << "\n");
|
DEBUG(dbgs() << "ObjCARCExpand: Visiting: " << *Inst << "\n");
|
||||||
|
|
||||||
switch (GetBasicInstructionClass(Inst)) {
|
switch (GetBasicInstructionClass(Inst)) {
|
||||||
case IC_Retain:
|
case IC_Retain:
|
||||||
case IC_RetainRV:
|
case IC_RetainRV:
|
||||||
|
@ -911,9 +911,9 @@ bool ObjCARCExpand::runOnFunction(Function &F) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCExpand: Finished List.\n\n");
|
DEBUG(dbgs() << "ObjCARCExpand: Finished List.\n\n");
|
||||||
|
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2199,13 +2199,13 @@ ObjCARCOpt::OptimizeRetainCall(Function &F, Instruction *Retain) {
|
||||||
// Turn it to an objc_retainAutoreleasedReturnValue..
|
// Turn it to an objc_retainAutoreleasedReturnValue..
|
||||||
Changed = true;
|
Changed = true;
|
||||||
++NumPeeps;
|
++NumPeeps;
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCOpt::OptimizeRetainCall: Transforming "
|
DEBUG(dbgs() << "ObjCARCOpt::OptimizeRetainCall: Transforming "
|
||||||
"objc_retainAutoreleasedReturnValue => "
|
"objc_retainAutoreleasedReturnValue => "
|
||||||
"objc_retain since the operand is not a return value.\n"
|
"objc_retain since the operand is not a return value.\n"
|
||||||
" Old: "
|
" Old: "
|
||||||
<< *Retain << "\n");
|
<< *Retain << "\n");
|
||||||
|
|
||||||
cast<CallInst>(Retain)->setCalledFunction(getRetainRVCallee(F.getParent()));
|
cast<CallInst>(Retain)->setCalledFunction(getRetainRVCallee(F.getParent()));
|
||||||
|
|
||||||
DEBUG(dbgs() << " New: "
|
DEBUG(dbgs() << " New: "
|
||||||
|
@ -2247,11 +2247,11 @@ ObjCARCOpt::OptimizeRetainRVCall(Function &F, Instruction *RetainRV) {
|
||||||
GetObjCArg(I) == Arg) {
|
GetObjCArg(I) == Arg) {
|
||||||
Changed = true;
|
Changed = true;
|
||||||
++NumPeeps;
|
++NumPeeps;
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCOpt::OptimizeRetainRVCall: Erasing " << *I << "\n"
|
DEBUG(dbgs() << "ObjCARCOpt::OptimizeRetainRVCall: Erasing " << *I << "\n"
|
||||||
<< " Erasing " << *RetainRV
|
<< " Erasing " << *RetainRV
|
||||||
<< "\n");
|
<< "\n");
|
||||||
|
|
||||||
EraseInstruction(I);
|
EraseInstruction(I);
|
||||||
EraseInstruction(RetainRV);
|
EraseInstruction(RetainRV);
|
||||||
return true;
|
return true;
|
||||||
|
@ -2261,13 +2261,13 @@ ObjCARCOpt::OptimizeRetainRVCall(Function &F, Instruction *RetainRV) {
|
||||||
// Turn it to a plain objc_retain.
|
// Turn it to a plain objc_retain.
|
||||||
Changed = true;
|
Changed = true;
|
||||||
++NumPeeps;
|
++NumPeeps;
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCOpt::OptimizeRetainRVCall: Transforming "
|
DEBUG(dbgs() << "ObjCARCOpt::OptimizeRetainRVCall: Transforming "
|
||||||
"objc_retainAutoreleasedReturnValue => "
|
"objc_retainAutoreleasedReturnValue => "
|
||||||
"objc_retain since the operand is not a return value.\n"
|
"objc_retain since the operand is not a return value.\n"
|
||||||
" Old: "
|
" Old: "
|
||||||
<< *RetainRV << "\n");
|
<< *RetainRV << "\n");
|
||||||
|
|
||||||
cast<CallInst>(RetainRV)->setCalledFunction(getRetainCallee(F.getParent()));
|
cast<CallInst>(RetainRV)->setCalledFunction(getRetainCallee(F.getParent()));
|
||||||
|
|
||||||
DEBUG(dbgs() << " New: "
|
DEBUG(dbgs() << " New: "
|
||||||
|
@ -2308,10 +2308,10 @@ ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV) {
|
||||||
|
|
||||||
cast<CallInst>(AutoreleaseRV)->
|
cast<CallInst>(AutoreleaseRV)->
|
||||||
setCalledFunction(getAutoreleaseCallee(F.getParent()));
|
setCalledFunction(getAutoreleaseCallee(F.getParent()));
|
||||||
|
|
||||||
DEBUG(dbgs() << " New: "
|
DEBUG(dbgs() << " New: "
|
||||||
<< *AutoreleaseRV << "\n");
|
<< *AutoreleaseRV << "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// OptimizeIndividualCalls - Visit each call, one at a time, and make
|
/// OptimizeIndividualCalls - Visit each call, one at a time, and make
|
||||||
|
@ -2361,12 +2361,12 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
|
||||||
new StoreInst(UndefValue::get(cast<PointerType>(Ty)->getElementType()),
|
new StoreInst(UndefValue::get(cast<PointerType>(Ty)->getElementType()),
|
||||||
Constant::getNullValue(Ty),
|
Constant::getNullValue(Ty),
|
||||||
CI);
|
CI);
|
||||||
llvm::Value *NewValue = UndefValue::get(CI->getType());
|
llvm::Value *NewValue = UndefValue::get(CI->getType());
|
||||||
DEBUG(dbgs() << "ObjCARCOpt::OptimizeIndividualCalls: A null "
|
DEBUG(dbgs() << "ObjCARCOpt::OptimizeIndividualCalls: A null "
|
||||||
"pointer-to-weak-pointer is undefined behavior.\n"
|
"pointer-to-weak-pointer is undefined behavior.\n"
|
||||||
" Old = " << *CI <<
|
" Old = " << *CI <<
|
||||||
"\n New = " <<
|
"\n New = " <<
|
||||||
*NewValue << "\n");
|
*NewValue << "\n");
|
||||||
CI->replaceAllUsesWith(NewValue);
|
CI->replaceAllUsesWith(NewValue);
|
||||||
CI->eraseFromParent();
|
CI->eraseFromParent();
|
||||||
continue;
|
continue;
|
||||||
|
@ -2390,7 +2390,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
|
||||||
" Old = " << *CI <<
|
" Old = " << *CI <<
|
||||||
"\n New = " <<
|
"\n New = " <<
|
||||||
*NewValue << "\n");
|
*NewValue << "\n");
|
||||||
|
|
||||||
CI->replaceAllUsesWith(NewValue);
|
CI->replaceAllUsesWith(NewValue);
|
||||||
CI->eraseFromParent();
|
CI->eraseFromParent();
|
||||||
continue;
|
continue;
|
||||||
|
@ -2425,14 +2425,14 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
|
||||||
Call->getArgOperand(0), "", Call);
|
Call->getArgOperand(0), "", Call);
|
||||||
NewCall->setMetadata(ImpreciseReleaseMDKind,
|
NewCall->setMetadata(ImpreciseReleaseMDKind,
|
||||||
MDNode::get(C, ArrayRef<Value *>()));
|
MDNode::get(C, ArrayRef<Value *>()));
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCOpt::OptimizeIndividualCalls: Replacing "
|
DEBUG(dbgs() << "ObjCARCOpt::OptimizeIndividualCalls: Replacing "
|
||||||
"objc_autorelease(x) with objc_release(x) since x is "
|
"objc_autorelease(x) with objc_release(x) since x is "
|
||||||
"otherwise unused.\n"
|
"otherwise unused.\n"
|
||||||
" Old: " << *Call <<
|
" Old: " << *Call <<
|
||||||
"\n New: " <<
|
"\n New: " <<
|
||||||
*NewCall << "\n");
|
*NewCall << "\n");
|
||||||
|
|
||||||
EraseInstruction(Call);
|
EraseInstruction(Call);
|
||||||
Inst = NewCall;
|
Inst = NewCall;
|
||||||
Class = IC_Release;
|
Class = IC_Release;
|
||||||
|
@ -3626,9 +3626,9 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
|
||||||
done:;
|
done:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCOpt::OptimizeWeakCalls: Finished List.\n\n");
|
DEBUG(dbgs() << "ObjCARCOpt::OptimizeWeakCalls: Finished List.\n\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// OptimizeSequences - Identify program paths which execute sequences of
|
/// OptimizeSequences - Identify program paths which execute sequences of
|
||||||
|
@ -3766,9 +3766,9 @@ void ObjCARCOpt::OptimizeReturns(Function &F) {
|
||||||
DependingInstructions.clear();
|
DependingInstructions.clear();
|
||||||
Visited.clear();
|
Visited.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCOpt::OptimizeReturns: Finished List.\n\n");
|
DEBUG(dbgs() << "ObjCARCOpt::OptimizeReturns: Finished List.\n\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjCARCOpt::doInitialization(Module &M) {
|
bool ObjCARCOpt::doInitialization(Module &M) {
|
||||||
|
@ -4027,20 +4027,20 @@ ObjCARCContract::ContractAutorelease(Function &F, Instruction *Autorelease,
|
||||||
|
|
||||||
Changed = true;
|
Changed = true;
|
||||||
++NumPeeps;
|
++NumPeeps;
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCContract::ContractAutorelease: Fusing "
|
DEBUG(dbgs() << "ObjCARCContract::ContractAutorelease: Fusing "
|
||||||
"retain/autorelease. Erasing: " << *Autorelease << "\n"
|
"retain/autorelease. Erasing: " << *Autorelease << "\n"
|
||||||
" Old Retain: "
|
" Old Retain: "
|
||||||
<< *Retain << "\n");
|
<< *Retain << "\n");
|
||||||
|
|
||||||
if (Class == IC_AutoreleaseRV)
|
if (Class == IC_AutoreleaseRV)
|
||||||
Retain->setCalledFunction(getRetainAutoreleaseRVCallee(F.getParent()));
|
Retain->setCalledFunction(getRetainAutoreleaseRVCallee(F.getParent()));
|
||||||
else
|
else
|
||||||
Retain->setCalledFunction(getRetainAutoreleaseCallee(F.getParent()));
|
Retain->setCalledFunction(getRetainAutoreleaseCallee(F.getParent()));
|
||||||
|
|
||||||
DEBUG(dbgs() << " New Retain: "
|
DEBUG(dbgs() << " New Retain: "
|
||||||
<< *Retain << "\n");
|
<< *Retain << "\n");
|
||||||
|
|
||||||
EraseInstruction(Autorelease);
|
EraseInstruction(Autorelease);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4190,9 +4190,9 @@ bool ObjCARCContract::runOnFunction(Function &F) {
|
||||||
SmallPtrSet<const BasicBlock *, 4> Visited;
|
SmallPtrSet<const BasicBlock *, 4> Visited;
|
||||||
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ) {
|
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ) {
|
||||||
Instruction *Inst = &*I++;
|
Instruction *Inst = &*I++;
|
||||||
|
|
||||||
DEBUG(dbgs() << "ObjCARCContract: Visiting: " << *Inst << "\n");
|
DEBUG(dbgs() << "ObjCARCContract: Visiting: " << *Inst << "\n");
|
||||||
|
|
||||||
// Only these library routines return their argument. In particular,
|
// Only these library routines return their argument. In particular,
|
||||||
// objc_retainBlock does not necessarily return its argument.
|
// objc_retainBlock does not necessarily return its argument.
|
||||||
InstructionClass Class = GetBasicInstructionClass(Inst);
|
InstructionClass Class = GetBasicInstructionClass(Inst);
|
||||||
|
@ -4251,10 +4251,10 @@ bool ObjCARCContract::runOnFunction(Function &F) {
|
||||||
ConstantPointerNull::get(cast<PointerType>(CI->getType()));
|
ConstantPointerNull::get(cast<PointerType>(CI->getType()));
|
||||||
Changed = true;
|
Changed = true;
|
||||||
new StoreInst(Null, CI->getArgOperand(0), CI);
|
new StoreInst(Null, CI->getArgOperand(0), CI);
|
||||||
|
|
||||||
DEBUG(dbgs() << "OBJCARCContract: Old = " << *CI << "\n"
|
DEBUG(dbgs() << "OBJCARCContract: Old = " << *CI << "\n"
|
||||||
<< " New = " << *Null << "\n");
|
<< " New = " << *Null << "\n");
|
||||||
|
|
||||||
CI->replaceAllUsesWith(Null);
|
CI->replaceAllUsesWith(Null);
|
||||||
CI->eraseFromParent();
|
CI->eraseFromParent();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue