From ade1a02eb22df880f3bd43e231d96159626e1542 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Fri, 8 Mar 2019 05:27:53 +0000 Subject: [PATCH] [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 llvm-svn: 355663 --- lib/IR/AutoUpgrade.cpp | 14 ++++++++++++++ test/Bitcode/upgrade-clang-arc-use.ll | 14 ++++++++++++++ test/Bitcode/upgrade-clang-arc-use.ll.bc | Bin 0 -> 1296 bytes 3 files changed, 28 insertions(+) create mode 100644 test/Bitcode/upgrade-clang-arc-use.ll create mode 100644 test/Bitcode/upgrade-clang-arc-use.ll.bc diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index 8ebe55a1ea3..a7d7c2dbc64 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -493,6 +493,12 @@ static bool UpgradeX86IntrinsicFunction(Function *F, StringRef Name, 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 *CI, Function *NewFn) { // 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); diff --git a/test/Bitcode/upgrade-clang-arc-use.ll b/test/Bitcode/upgrade-clang-arc-use.ll new file mode 100644 index 00000000000..db5481f06f6 --- /dev/null +++ b/test/Bitcode/upgrade-clang-arc-use.ll @@ -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(...) diff --git a/test/Bitcode/upgrade-clang-arc-use.ll.bc b/test/Bitcode/upgrade-clang-arc-use.ll.bc new file mode 100644 index 0000000000000000000000000000000000000000..ab9db6a092939268d737eed9be86f846f3891563 GIT binary patch literal 1296 zcmY*ZaY!3y6#wGIe3^+~QVlfL%aKzH4yrw)v$1ES$#tb=8H;R%{;^@A)w-eejA@K% z*)F}5OI;XgCnbOMk67Bm7z4)&8?1k5;x=)ixOQy*A=03gQk;aY+X@r5chQ#Z-Tl7z zz4yNNzW3gJ->uH>H6S1hU|Wk2Mo8lkW>;SW1EOy~o;uflLc(f--YERv~&)pqM7UV~hTK1UkvK=AV0y*mRuh>st z(pJ~qjKi=NpH5k-yosbC9`~9X>(PER*-|Fm)*d}cWoq@1N85#2iho|tXXJK0jz~D% zsI(6%qE#7B;|mGODay_abx4vc`+a11iA0NJI7PxoaMX`OOS%mSiy1s>$B`x7mV~2b z9M0e|`>ypXGY(34AL}Jw9^O7+`t-*yTKLVbud`1_KkqvD?eZpD#X%cilJSb}MyWYF z8h;|xhRrXnsH#>wnWYe#?*&~5(5jc{`2sy)(YO+VGoD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