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 | a918b88952a4449fb0f09c43ff20dd8ed46c7ce7 (patch) | |
| tree | 48ca99400f9da5b2f10e0ba6ab98dd21aba98114 /clang/lib | |
| parent | 561471d2f36826cdc98985ad10d28c5cc0534742 (diff) | |
| download | bcm5719-llvm-a918b88952a4449fb0f09c43ff20dd8ed46c7ce7.tar.gz bcm5719-llvm-a918b88952a4449fb0f09c43ff20dd8ed46c7ce7.zip | |
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.
llvm-svn: 134611
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 0f53cd668f4..9e6049a06e3 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/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); |

