[cfe-commits] r69061 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Apr 14 11:41:56 PDT 2009


Author: fjahanian
Date: Tue Apr 14 13:41:56 2009
New Revision: 69061

URL: http://llvm.org/viewvc/llvm-project?rev=69061&view=rev
Log:
Do not dead code strip global meta-data objects.
This will match gcc's behavior in the arena.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=69061&r1=69060&r2=69061&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Apr 14 13:41:56 2009
@@ -768,9 +768,8 @@
 
   /// GetClassGlobal - Return the global variable for the Objective-C
   /// class of the given name.
-  llvm::GlobalVariable *GetClassGlobal(const std::string &Name,
-                                       bool AddToUsed = true);
-  
+  llvm::GlobalVariable *GetClassGlobal(const std::string &Name);
+                                        
   /// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy,
   /// for the given class.
   llvm::Value *EmitClassRef(CGBuilderTy &Builder, 
@@ -4014,11 +4013,12 @@
   UsedGlobals.push_back(IMGV);
   
   std::vector<llvm::Constant*> Used;
+
   for (std::vector<llvm::GlobalVariable*>::iterator i = UsedGlobals.begin(), 
        e = UsedGlobals.end(); i != e; ++i) {
     Used.push_back(llvm::ConstantExpr::getBitCast(*i, ObjCTypes.Int8PtrTy));
   }
-  
+
   llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.Int8PtrTy, Used.size());
   llvm::GlobalValue *GV = 
   new llvm::GlobalVariable(AT, false,
@@ -4215,17 +4215,17 @@
     // class is root
     flags |= CLS_ROOT;
     SuperClassGV = GetClassGlobal(ObjCClassName + ClassName);
-    IsAGV = GetClassGlobal(ObjCMetaClassName + ClassName, false);
+    IsAGV = GetClassGlobal(ObjCMetaClassName + ClassName);
   } else {
     // Has a root. Current class is not a root.
     const ObjCInterfaceDecl *Root = ID->getClassInterface();
     while (const ObjCInterfaceDecl *Super = Root->getSuperClass())
       Root = Super;
-    IsAGV = GetClassGlobal(ObjCMetaClassName + Root->getNameAsString(), false);
+    IsAGV = GetClassGlobal(ObjCMetaClassName + Root->getNameAsString());
     // work on super class metadata symbol.
     std::string SuperClassName =  
       ObjCMetaClassName + ID->getClassInterface()->getSuperClass()->getNameAsString();
-    SuperClassGV = GetClassGlobal(SuperClassName, false);
+    SuperClassGV = GetClassGlobal(SuperClassName);
   }
   llvm::GlobalVariable *CLASS_RO_GV = BuildClassRoTInitializer(flags,
                                                                InstanceStart,
@@ -4290,7 +4290,6 @@
   llvm::GlobalVariable *ClassMD = 
     BuildClassMetaData(TClassName, MetaTClass, SuperClassGV, CLASS_RO_GV,
                        classIsHidden);
-  UsedGlobals.push_back(ClassMD);
   DefinedClasses.push_back(ClassMD);
 
   // Force the definition of the EHType if necessary.
@@ -4535,7 +4534,6 @@
   else
     IvarOffsetGV->setVisibility(llvm::GlobalValue::DefaultVisibility);
   IvarOffsetGV->setSection("__DATA, __objc_const");
-  UsedGlobals.push_back(IvarOffsetGV);
   return IvarOffsetGV;
 }
 
@@ -5029,16 +5027,13 @@
 }
 
 llvm::GlobalVariable *
-CGObjCNonFragileABIMac::GetClassGlobal(const std::string &Name,
-                                       bool AddToUsed) {
+CGObjCNonFragileABIMac::GetClassGlobal(const std::string &Name) {
   llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name);
 
   if (!GV) {
     GV = new llvm::GlobalVariable(ObjCTypes.ClassnfABITy, false,
                                   llvm::GlobalValue::ExternalLinkage,
                                   0, Name, &CGM.getModule());
-    if (AddToUsed)
-      UsedGlobals.push_back(GV);
   }
 
   return GV;
@@ -5084,7 +5079,7 @@
     return Builder.CreateLoad(Entry, false, "tmp");
   
   std::string MetaClassName(getMetaclassSymbolPrefix() + ID->getNameAsString());
-  llvm::GlobalVariable *MetaClassGV = GetClassGlobal(MetaClassName, false);
+  llvm::GlobalVariable *MetaClassGV = GetClassGlobal(MetaClassName);
   Entry = 
     new llvm::GlobalVariable(ObjCTypes.ClassnfABIPtrTy, false,
                              llvm::GlobalValue::InternalLinkage,
@@ -5598,7 +5593,7 @@
   std::vector<llvm::Constant*> Values(3);
   Values[0] = llvm::ConstantExpr::getGetElementPtr(VTableGV, &VTableIdx, 1);
   Values[1] = GetClassName(ID->getIdentifier());
-  Values[2] = GetClassGlobal(ClassName, false);
+  Values[2] = GetClassGlobal(ClassName);
   llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.EHTypeTy, Values);
 
   if (Entry) {





More information about the cfe-commits mailing list