diff options
author | Steven Wu <stevenwu@apple.com> | 2019-08-13 17:52:21 +0000 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2019-08-13 17:52:21 +0000 |
commit | 9e51fb6c576205c4ada59675d89443df10b4abff (patch) | |
tree | f6eef4df6ac416c71078805854f9d25bc7f3d65c /llvm/lib | |
parent | bbccb94d02ef70c06583f4804cc52a4678ddbc04 (diff) | |
download | bcm5719-llvm-9e51fb6c576205c4ada59675d89443df10b4abff.tar.gz bcm5719-llvm-9e51fb6c576205c4ada59675d89443df10b4abff.zip |
[AutoUpgrader] Make ArcRuntime Autoupgrader more conservative
Summary:
This is a tweak to r368311 and r368646 which auto upgrades the calls to
objc runtime functions to objc runtime intrinsics, in order to make sure
that the auto upgrader does not trigger with up-to-date bitcode.
It is possible for bitcode that is up-to-date to contain direct calls to
objc runtime function and those are not inserted by compiler as part of
ARC and they should not be upgraded. Now auto upgrader only triggers as
when the old style of ARC marker is used so it is guaranteed that it
won't trigger on update-to-date bitcode.
This also means it won't do this upgrade for bitcode from llvm-8 and
llvm-9, which preserves the behavior of those releases. Ideally they
should be upgraded as well but it is more important to make sure
AutoUpgrader will not trigger on up-to-date bitcode.
Reviewers: ahatanak, rjmccall, dexonsmith, pete
Reviewed By: dexonsmith
Subscribers: hiraditya, jkorous, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66153
llvm-svn: 368730
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index cba9385318c..997b556f0f9 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5312,8 +5312,7 @@ Error BitcodeReader::materializeModule() { UpgradeModuleFlags(*TheModule); - UpgradeRetainReleaseMarker(*TheModule); - UpgradeARCRuntimeCalls(*TheModule); + UpgradeARCRuntime(*TheModule); return Error::success(); } diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index e8443aeb715..e9d49d8a2b5 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -3830,7 +3830,9 @@ bool llvm::UpgradeDebugInfo(Module &M) { return Modified; } -bool llvm::UpgradeRetainReleaseMarker(Module &M) { +/// This checks for objc retain release marker which should be upgraded. It +/// returns true if module is modified. +static bool UpgradeRetainReleaseMarker(Module &M) { bool Changed = false; const char *MarkerKey = "clang.arc.retainAutoreleasedReturnValueMarker"; NamedMDNode *ModRetainReleaseMarker = M.getNamedMetadata(MarkerKey); @@ -3854,7 +3856,7 @@ bool llvm::UpgradeRetainReleaseMarker(Module &M) { return Changed; } -void llvm::UpgradeARCRuntimeCalls(Module &M) { +void llvm::UpgradeARCRuntime(Module &M) { // This lambda converts normal function calls to ARC runtime functions to // intrinsic calls. auto UpgradeToIntrinsic = [&](const char *OldFunc, @@ -3905,9 +3907,10 @@ void llvm::UpgradeARCRuntimeCalls(Module &M) { // "llvm.objc.clang.arc.use". UpgradeToIntrinsic("clang.arc.use", llvm::Intrinsic::objc_clang_arc_use); - // Return if the bitcode doesn't have the arm64 retainAutoreleasedReturnValue - // marker. We don't know for sure that it was compiled with ARC in that case. - if (!M.getModuleFlag("clang.arc.retainAutoreleasedReturnValueMarker")) + // Upgrade the retain release marker. If there is no need to upgrade + // the marker, that means either the module is already new enough to contain + // new intrinsics or it is not ARC. There is no need to upgrade runtime call. + if (!UpgradeRetainReleaseMarker(M)) return; std::pair<const char *, llvm::Intrinsic::ID> RuntimeFuncs[] = { |