aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCGNU.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGObjCGNU.cpp')
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp29
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);