llvm.org GIT mirror llvm / 6006c2a
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350261 91177308-0d34-0410-b5e6-96231b3b80d8 Pete Cooper 8 months ago
2 changed file(s) with 6 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
5757 // Replace the return value with the argument.
5858 assert((IsForwarding(GetBasicARCInstKind(CI)) ||
5959 (IsNoopOnNull(GetBasicARCInstKind(CI)) &&
60 isa(OldArg))) &&
60 IsNullOrUndef(OldArg->stripPointerCasts()))) &&
6161 "Can't delete non-forwarding instruction with users!");
6262 CI->replaceAllUsesWith(OldArg);
6363 }
6060 call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* null)
6161 call i8* @llvm.objc.autoreleaseReturnValue(i8* null)
6262 ; call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* null) ; TODO
63 %bitcast = bitcast i32* null to i8*
64 %rb = call i8* @llvm.objc.retainBlock(i8* %bitcast)
65 call void @use_pointer(i8* %rb)
66 %rb2 = call i8* @llvm.objc.retainBlock(i8* undef)
67 call void @use_pointer(i8* %rb2)
6368 ret void
6469 }
6570