1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Fix assert in ObjCARC optimizer when deleting retainBlock of null or undef.

The caller to EraseInstruction had this conditional:

    // ARC calls with null are no-ops. Delete them.
    if (IsNullOrUndef(Arg))

but the assert inside EraseInstruction only allowed ConstantPointerNull and not
undef or bitcasts.

This adds support for both of these cases.

rdar://problem/47003805

llvm-svn: 350261
This commit is contained in:
Pete Cooper 2019-01-02 21:00:02 +00:00
parent cad75f35f4
commit 3f14a0615c
2 changed files with 6 additions and 1 deletions

View File

@ -58,7 +58,7 @@ static inline void EraseInstruction(Instruction *CI) {
// Replace the return value with the argument.
assert((IsForwarding(GetBasicARCInstKind(CI)) ||
(IsNoopOnNull(GetBasicARCInstKind(CI)) &&
isa<ConstantPointerNull>(OldArg))) &&
IsNullOrUndef(OldArg->stripPointerCasts()))) &&
"Can't delete non-forwarding instruction with users!");
CI->replaceAllUsesWith(OldArg);
}

View File

@ -61,6 +61,11 @@ define void @test2() {
call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* null)
call i8* @llvm.objc.autoreleaseReturnValue(i8* null)
; call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* null) ; TODO
%bitcast = bitcast i32* null to i8*
%rb = call i8* @llvm.objc.retainBlock(i8* %bitcast)
call void @use_pointer(i8* %rb)
%rb2 = call i8* @llvm.objc.retainBlock(i8* undef)
call void @use_pointer(i8* %rb2)
ret void
}