r193359 - ObjectiveC IRGen. Replace _objc_empty_vtable pointer in Objective-C
Fariborz Jahanian
fjahanian at apple.com
Thu Oct 24 10:40:29 PDT 2013
Author: fjahanian
Date: Thu Oct 24 12:40:28 2013
New Revision: 193359
URL: http://llvm.org/viewvc/llvm-project?rev=193359&view=rev
Log:
ObjectiveC IRGen. Replace _objc_empty_vtable pointer in Objective-C
class metadata for certain deployment targets. // rdar://14802916
Added:
cfe/trunk/test/CodeGenObjC/null-objc-empty-vtable.m
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=193359&r1=193358&r2=193359&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Oct 24 12:40:28 2013
@@ -5757,6 +5757,9 @@ llvm::GlobalVariable * CGObjCNonFragileA
};
if (!Values[1])
Values[1] = llvm::Constant::getNullValue(ObjCTypes.ClassnfABIPtrTy);
+ if (!Values[3])
+ Values[3] = llvm::Constant::getNullValue(
+ llvm::PointerType::getUnqual(ObjCTypes.ImpnfABITy));
llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ClassnfABITy,
Values);
llvm::GlobalVariable *GV = GetClassGlobal(ClassName);
@@ -5800,14 +5803,21 @@ void CGObjCNonFragileABIMac::GenerateCla
llvm::GlobalValue::ExternalLinkage,
0,
"_objc_empty_cache");
-
- ObjCEmptyVtableVar = new llvm::GlobalVariable(
- CGM.getModule(),
- ObjCTypes.ImpnfABITy,
- false,
- llvm::GlobalValue::ExternalLinkage,
- 0,
- "_objc_empty_vtable");
+
+ // Make this entry NULL for any iOS device target, any iOS simulator target,
+ // OS X with deployment target 10.9 or later.
+ const llvm::Triple &Triple = CGM.getTarget().getTriple();
+ if (Triple.isiOS() || (Triple.isMacOSX() && !Triple.isMacOSXVersionLT(10, 9)))
+ // This entry will be null.
+ ObjCEmptyVtableVar = 0;
+ else
+ ObjCEmptyVtableVar = new llvm::GlobalVariable(
+ CGM.getModule(),
+ ObjCTypes.ImpnfABITy,
+ false,
+ llvm::GlobalValue::ExternalLinkage,
+ 0,
+ "_objc_empty_vtable");
}
assert(ID->getClassInterface() &&
"CGObjCNonFragileABIMac::GenerateClass - class is 0");
Added: cfe/trunk/test/CodeGenObjC/null-objc-empty-vtable.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/null-objc-empty-vtable.m?rev=193359&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/null-objc-empty-vtable.m (added)
+++ cfe/trunk/test/CodeGenObjC/null-objc-empty-vtable.m Thu Oct 24 12:40:28 2013
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -emit-llvm -o - %s | FileCheck -check-prefix CHECK-OSX %s
+// RUN: %clang_cc1 -triple thumbv7-apple-ios3.0.0 -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IOS %s
+// rdar://14802916
+
+ at interface I
+ at end
+
+ at implementation I @end
+// CHECK-OSX: %struct._class_t* null, %struct._objc_cache* @_objc_empty_cache, i8* (i8*, i8*)** null
+// CHECK-IOS: %struct._class_t* null, %struct._objc_cache* @_objc_empty_cache, i8* (i8*, i8*)** null
More information about the cfe-commits
mailing list