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