[llvm] r355663 - [Bitcode] Fix bitcode compatibility issue with clang.arc.use intrinsic

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 21:27:53 PST 2019


Author: steven_wu
Date: Thu Mar  7 21:27:53 2019
New Revision: 355663

URL: http://llvm.org/viewvc/llvm-project?rev=355663&view=rev
Log:
[Bitcode] Fix bitcode compatibility issue with clang.arc.use intrinsic

Summary:
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

Reviewers: pete, ahatanak, erik.pilkington, dexonsmith

Reviewed By: pete, dexonsmith

Subscribers: jkorous, jdoerfert, llvm-commits

Tags: #llvm

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

Added:
    llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll
    llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll.bc
Modified:
    llvm/trunk/lib/IR/AutoUpgrade.cpp

Modified: llvm/trunk/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AutoUpgrade.cpp?rev=355663&r1=355662&r2=355663&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/IR/AutoUpgrade.cpp Thu Mar  7 21:27:53 2019
@@ -493,6 +493,12 @@ static bool UpgradeX86IntrinsicFunction(
 static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
   assert(F && "Illegal to upgrade a non-existent Function.");
 
+  // Upgrade intrinsics "clang.arc.use" which doesn't start with "llvm.".
+  if (F->getName() == "clang.arc.use") {
+    NewFn = nullptr;
+    return true;
+  }
+
   // Quickly eliminate it, if it's not a candidate.
   StringRef Name = F->getName();
   if (Name.size() <= 8 || !Name.startswith("llvm."))
@@ -1571,6 +1577,14 @@ void llvm::UpgradeIntrinsicCall(CallInst
     // Get the Function's name.
     StringRef Name = F->getName();
 
+    // clang.arc.use is an old name for llvm.arc.clang.arc.use. It is dropped
+    // from upgrader because the optimizer now only recognizes intrinsics for
+    // ARC runtime calls.
+    if (Name == "clang.arc.use") {
+      CI->eraseFromParent();
+      return;
+    }
+
     assert(Name.startswith("llvm.") && "Intrinsic doesn't start with 'llvm.'");
     Name = Name.substr(5);
 

Added: llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll?rev=355663&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll (added)
+++ llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll Thu Mar  7 21:27:53 2019
@@ -0,0 +1,14 @@
+; Test upgrade of clang.arc.use by removing it.
+; Bitcode input generated from llvm 6.0
+
+; 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(...)

Added: llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll.bc?rev=355663&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll.bc (added) and llvm/trunk/test/Bitcode/upgrade-clang-arc-use.ll.bc Thu Mar  7 21:27:53 2019 differ




More information about the llvm-commits mailing list