forked from OSchip/llvm-project
Don't convert objc_autoreleaseReturnValue to objc_autorelease if the result
is returned through a bitcast. llvm-svn: 137402
This commit is contained in:
parent
9b25cee36f
commit
10a18d55ce
|
@ -1925,12 +1925,19 @@ void
|
||||||
ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV) {
|
ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV) {
|
||||||
// Check for a return of the pointer value.
|
// Check for a return of the pointer value.
|
||||||
const Value *Ptr = GetObjCArg(AutoreleaseRV);
|
const Value *Ptr = GetObjCArg(AutoreleaseRV);
|
||||||
for (Value::const_use_iterator UI = Ptr->use_begin(), UE = Ptr->use_end();
|
SmallVector<const Value *, 2> Users;
|
||||||
UI != UE; ++UI) {
|
Users.push_back(Ptr);
|
||||||
const User *I = *UI;
|
do {
|
||||||
if (isa<ReturnInst>(I) || GetBasicInstructionClass(I) == IC_RetainRV)
|
Ptr = Users.pop_back_val();
|
||||||
return;
|
for (Value::const_use_iterator UI = Ptr->use_begin(), UE = Ptr->use_end();
|
||||||
}
|
UI != UE; ++UI) {
|
||||||
|
const User *I = *UI;
|
||||||
|
if (isa<ReturnInst>(I) || GetBasicInstructionClass(I) == IC_RetainRV)
|
||||||
|
return;
|
||||||
|
if (isa<BitCastInst>(I))
|
||||||
|
Users.push_back(I);
|
||||||
|
}
|
||||||
|
} while (!Users.empty());
|
||||||
|
|
||||||
Changed = true;
|
Changed = true;
|
||||||
++NumPeeps;
|
++NumPeeps;
|
||||||
|
|
|
@ -329,3 +329,14 @@ define void @test23(i8* %p) {
|
||||||
call i8* @objc_autoreleaseReturnValue(i8* %p)
|
call i8* @objc_autoreleaseReturnValue(i8* %p)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Don't convert autoreleaseRV to autorelease if the result is returned,
|
||||||
|
; even through a bitcast.
|
||||||
|
|
||||||
|
; CHECK: define {}* @test24(
|
||||||
|
; CHECK: tail call i8* @objc_autoreleaseReturnValue(i8* %p)
|
||||||
|
define {}* @test24(i8* %p) {
|
||||||
|
%t = call i8* @objc_autoreleaseReturnValue(i8* %p)
|
||||||
|
%s = bitcast i8* %p to {}*
|
||||||
|
ret {}* %s
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue