[PATCH] D59112: [Bitcode] Fix bitcode compatibility issue with clang.arc.use intrinsic
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 14:51:48 PST 2019
steven_wu created this revision.
steven_wu added reviewers: pete, ahatanak, erik.pilkington, dexonsmith.
Herald added subscribers: jdoerfert, jkorous.
Herald added a project: LLVM.
In r349534, objc arc implementation is switched to use intrinsics and at
the same time, clang.arc.use is renamed to llvm.objc.clang.arc.use to
make the naming more consistent. The side-effect of that is llvm no
longer recognize it as intrinsics and codegen external references to
it instead.
Rather than upgrade the old intrinsics name to the new one and wait for
the arc-contract pass to remove it, simply remove it in the bitcode
upgrader.
rdar://problem/48607063
Repository:
rL LLVM
https://reviews.llvm.org/D59112
Files:
lib/IR/AutoUpgrade.cpp
test/Bitcode/upgrade-clang-arc-use.ll
test/Bitcode/upgrade-clang-arc-use.ll.bc
Index: test/Bitcode/upgrade-clang-arc-use.ll
===================================================================
--- /dev/null
+++ test/Bitcode/upgrade-clang-arc-use.ll
@@ -0,0 +1,13 @@
+; Test upgrade of clang.arc.use by removing it.
+
+; RUN: llvm-dis %s.bc -o - | FileCheck %s
+
+%0 = type opaque
+define void @foo() {
+ %1 = tail call %0* @foo0()
+; CHECK-NOT: clang.arc.use
+ call void (...) @clang.arc.use(%0* %1)
+ ret void
+}
+declare %0* @foo0()
+declare void @clang.arc.use(...)
Index: lib/IR/AutoUpgrade.cpp
===================================================================
--- lib/IR/AutoUpgrade.cpp
+++ lib/IR/AutoUpgrade.cpp
@@ -778,9 +778,20 @@
return false;
}
+static bool UpgradeIntrinsicFunction2(Function *F, Function *&NewFn) {
+ // Upgrade intrinsics that have the old name not beginning with "llvm.".
+ if (F->getName() == "clang.arc.use") {
+ NewFn = nullptr;
+ return true;
+ }
+
+ return false;
+}
+
bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) {
NewFn = nullptr;
- bool Upgraded = UpgradeIntrinsicFunction1(F, NewFn);
+ bool Upgraded = UpgradeIntrinsicFunction1(F, NewFn) ||
+ UpgradeIntrinsicFunction2(F, NewFn);
assert(F != NewFn && "Intrinsic function upgraded to the same function");
// Upgrade intrinsic attributes. This does not change the function.
@@ -1571,6 +1582,12 @@
// Get the Function's name.
StringRef Name = F->getName();
+ // Handle clang.arc.use.
+ if (Name == "clang.arc.use") {
+ CI->eraseFromParent();
+ return;
+ }
+
assert(Name.startswith("llvm.") && "Intrinsic doesn't start with 'llvm.'");
Name = Name.substr(5);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59112.189787.patch
Type: text/x-patch
Size: 1682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190307/4e2a6187/attachment.bin>
More information about the llvm-commits
mailing list