[cfe-commits] r102312 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/image-info.m

Daniel Dunbar daniel at zuster.org
Sun Apr 25 13:39:02 PDT 2010


Author: ddunbar
Date: Sun Apr 25 15:39:01 2010
New Revision: 102312

URL: http://llvm.org/viewvc/llvm-project?rev=102312&view=rev
Log:
IRgen/NeXT: Reuse EmitImageInfo for both fragile and non-fragile ABI. This fixes Clang to correctly emit the "CorrectedSynthesize" bit when using the non-fragile ABI.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/test/CodeGenObjC/image-info.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=102312&r1=102311&r2=102312&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Apr 25 15:39:01 2010
@@ -982,6 +982,10 @@
                                         const ObjCMethodDecl *OMD,
                                         const ObjCCommonTypesHelper &ObjCTypes);
 
+  /// EmitImageInfo - Emit the image info marker used to encode some module
+  /// level information.
+  void EmitImageInfo();
+
 public:
   CGObjCCommonMac(CodeGen::CodeGenModule &cgm) :
     CGM(cgm), VMContext(cgm.getLLVMContext()) { }
@@ -1008,9 +1012,6 @@
 class CGObjCMac : public CGObjCCommonMac {
 private:
   ObjCTypesHelper ObjCTypes;
-  /// EmitImageInfo - Emit the image info marker used to encode some module
-  /// level information.
-  void EmitImageInfo();
 
   /// EmitModuleInfo - Another marker encoding module level
   /// information.
@@ -1741,7 +1742,6 @@
                                Init,
                                "\01L_OBJC_PROTOCOL_" + PD->getName());
     Entry->setSection("__OBJC,__protocol,regular,no_dead_strip");
-    Entry->setAlignment(4);
     // FIXME: Is this necessary? Why only for protocol?
     Entry->setAlignment(4);
   }
@@ -1763,7 +1763,6 @@
                                0,
                                "\01L_OBJC_PROTOCOL_" + PD->getName());
     Entry->setSection("__OBJC,__protocol,regular,no_dead_strip");
-    Entry->setAlignment(4);
     // FIXME: Is this necessary? Why only for protocol?
     Entry->setAlignment(4);
   }
@@ -2962,18 +2961,17 @@
 ///   unsigned flags;
 /// };
 enum ImageInfoFlags {
-  eImageInfo_FixAndContinue      = (1 << 0), // FIXME: Not sure what
-                                             // this implies.
+  eImageInfo_FixAndContinue      = (1 << 0),
   eImageInfo_GarbageCollected    = (1 << 1),
   eImageInfo_GCOnly              = (1 << 2),
   eImageInfo_OptimizedByDyld     = (1 << 3), // FIXME: When is this set.
 
-  // A flag indicating that the module has no instances of an
-  // @synthesize of a superclass variable. <rdar://problem/6803242>
+  // A flag indicating that the module has no instances of a @synthesize of a
+  // superclass variable. <rdar://problem/6803242>
   eImageInfo_CorrectedSynthesize = (1 << 4)
 };
 
-void CGObjCMac::EmitImageInfo() {
+void CGObjCCommonMac::EmitImageInfo() {
   unsigned version = 0; // Version is unused?
   unsigned flags = 0;
 
@@ -4245,28 +4243,7 @@
                      "\01L_OBJC_LABEL_NONLAZY_CATEGORY_$",
                      "__DATA, __objc_nlcatlist, regular, no_dead_strip");
 
-  //  static int L_OBJC_IMAGE_INFO[2] = { 0, flags };
-  // FIXME. flags can be 0 | 1 | 2 | 6. For now just use 0
-  std::vector<llvm::Constant*> Values(2);
-  Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, 0);
-  unsigned int flags = 0;
-  // FIXME: Fix and continue?
-  if (CGM.getLangOptions().getGCMode() != LangOptions::NonGC)
-    flags |= eImageInfo_GarbageCollected;
-  if (CGM.getLangOptions().getGCMode() == LangOptions::GCOnly)
-    flags |= eImageInfo_GCOnly;
-  Values[1] = llvm::ConstantInt::get(ObjCTypes.IntTy, flags);
-  llvm::Constant* Init = llvm::ConstantArray::get(
-    llvm::ArrayType::get(ObjCTypes.IntTy, 2),
-    Values);
-  llvm::GlobalVariable *IMGV =
-    new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
-                             llvm::GlobalValue::InternalLinkage,
-                             Init,
-                             "\01L_OBJC_IMAGE_INFO");
-  IMGV->setSection("__DATA, __objc_imageinfo, regular, no_dead_strip");
-  IMGV->setConstant(true);
-  CGM.AddUsedGlobal(IMGV);
+  EmitImageInfo();
 }
 
 /// LegacyDispatchedSelector - Returns true if SEL is not in the list of

Modified: cfe/trunk/test/CodeGenObjC/image-info.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/image-info.m?rev=102312&r1=102311&r2=102312&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/image-info.m (original)
+++ cfe/trunk/test/CodeGenObjC/image-info.m Sun Apr 25 15:39:01 2010
@@ -1,2 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
-// RUN: grep -F '@"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__OBJC, __image_info,regular"' %t
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-NONFRAGILE < %t %s
+
+// CHECK-FRAGILE: @"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__OBJC, __image_info,regular"
+// CHECK-NONFRAGILE: @"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__DATA, __objc_imageinfo, regular, no_dead_strip"





More information about the cfe-commits mailing list