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
// 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);
}
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
}