Add clang.arc.used to ModuleHasARC so ARC always runs if said call is present in...
authorMichael Gottesman <mgottesman@apple.com>
Fri, 29 Mar 2013 21:15:23 +0000 (21:15 +0000)
committerMichael Gottesman <mgottesman@apple.com>
Fri, 29 Mar 2013 21:15:23 +0000 (21:15 +0000)
clang.arc.used is an interesting call for ARC since ObjCARCContract
needs to run to remove said intrinsic to avoid a linker error (since the
call does not exist).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178369 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/ObjCARC/ObjCARC.h
test/Transforms/ObjCARC/clang-arc-used-intrinsic-removed-if-isolated.ll [new file with mode: 0644]

index 614fa29e3e60ffdd13b20ecbaadfdd19005bdfc5..39670f339e9f3e93334ed169333482037465d53c 100644 (file)
@@ -64,7 +64,8 @@ static inline bool ModuleHasARC(const Module &M) {
     M.getNamedValue("objc_copyWeak") ||
     M.getNamedValue("objc_retainedObject") ||
     M.getNamedValue("objc_unretainedObject") ||
-    M.getNamedValue("objc_unretainedPointer");
+    M.getNamedValue("objc_unretainedPointer") ||
+    M.getNamedValue("clang.arc.use");
 }
 
 /// \enum InstructionClass
diff --git a/test/Transforms/ObjCARC/clang-arc-used-intrinsic-removed-if-isolated.ll b/test/Transforms/ObjCARC/clang-arc-used-intrinsic-removed-if-isolated.ll
new file mode 100644 (file)
index 0000000..4215b5c
--- /dev/null
@@ -0,0 +1,16 @@
+; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
+
+; This file makes sure that clang.arc.used is removed even if no other ARC
+; interesting calls are in the module.
+
+declare void @clang.arc.use(...) nounwind
+
+; Kill calls to @clang.arc.use(...)
+; CHECK: define void @test0(
+; CHECK-NOT: clang.arc.use
+; CHECK: }
+define void @test0(i8* %a, i8* %b) {
+  call void (...)* @clang.arc.use(i8* %a, i8* %b) nounwind
+  ret void
+}
+