Do not call replaceAllUsesWith to upgrade calls to ARC runtime functions
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 13 Aug 2019 01:23:06 +0000 (01:23 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 13 Aug 2019 01:23:06 +0000 (01:23 +0000)
commit3c7c053145fa98a017d426b475a9cf9c001c9da1
tree95f92886df75a73e72dcabef1f492564849f93e8
parent438315bf69c7dae68edd5c99f9672fffdc442a79
Do not call replaceAllUsesWith to upgrade calls to ARC runtime functions
to intrinsic calls

This fixes a bug in r368311.

It turns out that the ARC runtime functions in the IR can have pointer
parameter types that are not i8* or i8**. Instead of RAUWing normal
functions with intrinsics, manually bitcast the arguments before passing
them to the intrinsic functions and bitcast the return value back to the
type of the original call instruction.

This recommits r368634, which was reverted in r368637. The loop in the
patch was iterating over uses of a function and deleting function calls
inside it, which caused bots to crash.

rdar://problem/54125406

Differential Revision: https://reviews.llvm.org/D66047

llvm-svn: 368646
llvm/lib/IR/AutoUpgrade.cpp
llvm/test/Bitcode/upgrade-arc-runtime-calls.bc
llvm/test/Bitcode/upgrade-arc-runtime-calls.ll
llvm/test/Bitcode/upgrade-mrr-runtime-calls.bc