[cfe-commits] r70691 - in /cfe/trunk/lib/CodeGen: CGObjCGNU.cpp CGObjCMac.cpp CGObjCRuntime.h

Daniel Dunbar daniel at zuster.org
Sun May 3 03:46:52 PDT 2009


Author: ddunbar
Date: Sun May  3 05:46:44 2009
New Revision: 70691

URL: http://llvm.org/viewvc/llvm-project?rev=70691&view=rev
Log:
Compute Objective-C metadata size information from the record layout,
not the shadow structure.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/CodeGen/CGObjCRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=70691&r1=70690&r2=70691&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Sun May  3 05:46:44 2009
@@ -20,6 +20,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtObjC.h"
 #include "llvm/Module.h"
 #include "llvm/ADT/SmallVector.h"
@@ -742,18 +743,13 @@
     const_cast<ObjCInterfaceDecl *>(OID->getClassInterface());
   std::string ClassName = ClassDecl->getNameAsString();
 
-  // Get the size of instances.  For runtimes that support late-bound instances
-  // this should probably be something different (size just of instance
-  // varaibles in this class, not superclasses?).
-  const llvm::Type *ObjTy = 
-    CGObjCRuntime::GetConcreteClassStruct(CGM, ClassDecl);
-  int instanceSize = CGM.getTargetData().getTypePaddedSize(ObjTy);
+  // Get the size of instances.
+  int instanceSize = Context.getASTObjCImplementationLayout(OID).getSize() / 8;
 
   // Collect information about instance variables.
   llvm::SmallVector<llvm::Constant*, 16> IvarNames;
   llvm::SmallVector<llvm::Constant*, 16> IvarTypes;
   llvm::SmallVector<llvm::Constant*, 16> IvarOffsets;
-  ObjTy = llvm::PointerType::getUnqual(ObjTy);
   for (ObjCInterfaceDecl::ivar_iterator iter = ClassDecl->ivar_begin(),
       endIter = ClassDecl->ivar_end() ; iter != endIter ; iter++) {
       // Store the name

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=70691&r1=70690&r2=70691&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun May  3 05:46:44 2009
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/Basic/LangOptions.h"
 
@@ -34,9 +35,9 @@
 // don't belong in CGObjCRuntime either so we will live with it for
 // now.
 
-const llvm::StructType *
-CGObjCRuntime::GetConcreteClassStruct(CodeGen::CodeGenModule &CGM,
-                                      const ObjCInterfaceDecl *OID) {
+static const llvm::StructType *
+GetConcreteClassStruct(CodeGen::CodeGenModule &CGM,
+                       const ObjCInterfaceDecl *OID) {
   assert(!OID->isForwardDecl() && "Invalid interface decl!");
   const RecordDecl *RD = CGM.getContext().addRecordToClass(OID);
   return cast<llvm::StructType>(CGM.getTypes().ConvertTagDeclType(RD));
@@ -65,7 +66,7 @@
   //
   // FIXME: This is slow, we shouldn't need to do this.
   const ObjCInterfaceDecl *Super = OID->getSuperClass();
-  assert(OID && "field decl not found!");
+  assert(Super && "field decl not found!");
   return LookupFieldDeclForIvar(Context, Super, OIVD, Found);
 }
 
@@ -77,7 +78,7 @@
   const FieldDecl *Field = 
     LookupFieldDeclForIvar(CGM.getContext(), OID, Ivar, Container);
   const llvm::StructType *STy = 
-    CGObjCRuntime::GetConcreteClassStruct(CGM, Container);
+    GetConcreteClassStruct(CGM, Container);
   const llvm::StructLayout *Layout = 
     CGM.getTargetData().getStructLayout(STy);
   if (!Field->isBitField())
@@ -1855,10 +1856,9 @@
     EmitProtocolList("\01L_OBJC_CLASS_PROTOCOLS_" + ID->getNameAsString(),
                      Interface->protocol_begin(),
                      Interface->protocol_end());
-  const llvm::Type *InterfaceTy = 
-    CGObjCRuntime::GetConcreteClassStruct(CGM, Interface);
   unsigned Flags = eClassFlags_Factory;
-  unsigned Size = CGM.getTargetData().getTypePaddedSize(InterfaceTy);
+  unsigned Size = 
+    CGM.getContext().getASTObjCImplementationLayout(ID).getSize() / 8;
 
   // FIXME: Set CXX-structors flag.
   if (CGM.getDeclVisibilityMode(ID->getClassInterface()) == LangOptions::Hidden)

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=70691&r1=70690&r2=70691&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Sun May  3 05:46:44 2009
@@ -66,12 +66,6 @@
   // eventually be folded into other places (the structure layout
   // code).
 
-  /// Return the (fixed) LLVM struct type for the interface. This is
-  /// only very meaningful for runtimes which use a non-fragile ABI.
-  static 
-  const llvm::StructType * GetConcreteClassStruct(CodeGen::CodeGenModule &CGM,
-                                                  const ObjCInterfaceDecl *OID);
-
 protected:
   /// Compute an offset to the given ivar, suitable for passing to
   /// EmitValueForIvarAtOffset.  Note that the correct handling of





More information about the cfe-commits mailing list