--- Merging r77276 into 'gcc/objc/objc-act.c':
U    gcc/objc/objc-act.c

LTO was stripping some Objective-C metadata symbols because IPSCCP thought that
they were dead. They weren't in the llvm.used list. Mark them as "preserve" so
that they're placed into the list.

The testcase for this is the SingleSource/UnitTests/ObjC/protocols.m file in
the test suite.

llvm-svn: 77277
diff --git a/llvm-gcc-4.2/gcc/objc/objc-act.c b/llvm-gcc-4.2/gcc/objc/objc-act.c
index 7ca066f..696d01b 100644
--- a/llvm-gcc-4.2/gcc/objc/objc-act.c
+++ b/llvm-gcc-4.2/gcc/objc/objc-act.c
@@ -6200,6 +6200,9 @@
      follow from the alignments of the component types. */
   DECL_ALIGN(decl) = BITS_PER_WORD==32 ? 32 : 128;
   DECL_USER_ALIGN(decl) = 1;
+
+  /* Let optimizer know that this decl is not removable.  */
+  DECL_PRESERVE_P (decl) = 1;
 #endif
   /* LLVM LOCAL end */
   set_user_assembler_name (decl, buf);
@@ -12504,6 +12507,12 @@
       decl = create_hidden_decl (objc_protocol_type, string);
       DECL_WEAK (decl) = 1;
       set_user_assembler_name (decl, string);
+      /* LLVM LOCAL begin 7069676 */
+#ifdef ENABLE_LLVM
+      /* Let optimizer know that this decl is not removable.  */
+      DECL_PRESERVE_P (decl) = 1;
+#endif
+      /* LLVM LOCAL end 7069676 */
       expr = convert (objc_protocol_type, build_fold_addr_expr (expr));
       /* APPLE LOCAL radar 4561192 */
       objc_set_alignment_attribute (decl, objc_protocol_type);
@@ -12615,7 +12624,12 @@
   decl = create_hidden_decl (objc_protocol_type, buf);
   DECL_WEAK (decl) = 1;
   set_user_assembler_name (decl, buf);
-
+  /* LLVM LOCAL begin 7069676 */
+#ifdef ENABLE_LLVM
+  /* Let optimizer know that this decl is not removable.  */
+  DECL_PRESERVE_P (decl) = 1;
+#endif
+  /* LLVM LOCAL end 7069676 */
   return decl;
 }
 /* APPLE LOCAL end radar 6351990 */
@@ -14194,6 +14208,10 @@
   PROTOCOL_V2_FORWARD_DECL (p) = decl;
   /* LLVM LOCAL begin - radar 5476262 */
 #ifdef ENABLE_LLVM
+  /* begin radar 7069676 */
+  /* Let optimizer know that this decl is not removable.  */
+  DECL_PRESERVE_P (decl) = 1;
+  /* end radar 7069676 */
   pushdecl_top_level(decl);
 #endif
   /* LLVM LOCAL end - radar 5476262 */