[cfe-commits] r134611 - /cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

David Chisnall csdavec at swan.ac.uk
Thu Jul 7 04:22:32 PDT 2011


Author: theraven
Date: Thu Jul  7 06:22:31 2011
New Revision: 134611

URL: http://llvm.org/viewvc/llvm-project?rev=134611&view=rev
Log:
Set a flag to tell the runtime when we're compiling in ARC mode and use the pure-nonfragile ABI for both ARC and GC mode.


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

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=134611&r1=134610&r2=134611&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Thu Jul  7 06:22:31 2011
@@ -744,12 +744,15 @@
   IMPTy = llvm::PointerType::getUnqual(llvm::FunctionType::get(IdTy, IMPArgs,
               true));
 
+  const LangOptions &Opts = CGM.getLangOptions();
+  if ((Opts.getGCMode() != LangOptions::NonGC) || Opts.ObjCAutoRefCount)
+    RuntimeVersion = 10;
+
   // Don't bother initialising the GC stuff unless we're compiling in GC mode
-  if (CGM.getLangOptions().getGCMode() != LangOptions::NonGC) {
+  if (Opts.getGCMode() != LangOptions::NonGC) {
     // This is a bit of an hack.  We should sort this out by having a proper
     // CGObjCGNUstep subclass for GC, but we may want to really support the old
     // ABI and GC added in ObjectiveC2.framework, so we fudge it a bit for now
-    RuntimeVersion = 10;
     // Get selectors needed in GC mode
     RetainSel = GetNullarySelector("retain", CGM.getContext());
     ReleaseSel = GetNullarySelector("release", CGM.getContext());
@@ -2149,8 +2152,7 @@
   // constants
   llvm::StructType * ModuleTy = llvm::StructType::get(LongTy, LongTy,
       PtrToInt8Ty, llvm::PointerType::getUnqual(SymTabTy), 
-      (CGM.getLangOptions().getGCMode() == LangOptions::NonGC) ? NULL : IntTy,
-      NULL);
+      (RuntimeVersion >= 10) ? IntTy : NULL, NULL);
   Elements.clear();
   // Runtime version, used for ABI compatibility checking.
   Elements.push_back(llvm::ConstantInt::get(LongTy, RuntimeVersion));
@@ -2169,14 +2171,21 @@
   Elements.push_back(MakeConstantString(path, ".objc_source_file_name"));
   Elements.push_back(SymTab);
 
-  switch (CGM.getLangOptions().getGCMode()) {
-    case LangOptions::GCOnly:
+  if (RuntimeVersion >= 10)
+    switch (CGM.getLangOptions().getGCMode()) {
+      case LangOptions::GCOnly:
         Elements.push_back(llvm::ConstantInt::get(IntTy, 2));
-    case LangOptions::NonGC:
         break;
-    case LangOptions::HybridGC:
-        Elements.push_back(llvm::ConstantInt::get(IntTy, 1));
-  }
+      case LangOptions::NonGC:
+        if (CGM.getLangOptions().ObjCAutoRefCount)
+          Elements.push_back(llvm::ConstantInt::get(IntTy, 1));
+        else
+          Elements.push_back(llvm::ConstantInt::get(IntTy, 0));
+        break;
+      case LangOptions::HybridGC:
+          Elements.push_back(llvm::ConstantInt::get(IntTy, 1));
+        break;
+    }
 
   llvm::Value *Module = MakeGlobal(ModuleTy, Elements);
 





More information about the cfe-commits mailing list