diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2011-07-07 11:22:31 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2011-07-07 11:22:31 +0000 |
commit | f074885425af40e5e03569371e453d9f7ae43aa6 (patch) | |
tree | b818429cc0c245ab468b2fa2f794fa62fba28f70 /lib/CodeGen/CGObjCGNU.cpp | |
parent | cfe1f051915bc159cda244c8d08ea6fcca605de4 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCGNU.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 0f53cd668f..9e6049a06e 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -744,12 +744,15 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, 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 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { // 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 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { 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); |