From e05cc98e97ec910829beccd0d890a002ce5ab909 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 3 May 2009 23:35:23 +0000 Subject: [PATCH] Inline GetFieldBaseOffset into sole callsite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70813 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGObjCMac.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index e7733d9786..5441b8e362 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -845,11 +845,6 @@ protected: /// defined. The return value has type ProtocolPtrTy. llvm::Constant *GetProtocolRef(const ObjCProtocolDecl *PD); - /// GetFieldBaseOffset - return's field byte offset. - uint64_t GetFieldBaseOffset(const ObjCImplementationDecl *OI, - const llvm::StructLayout *Layout, - const FieldDecl *Field); - /// CreateMetadataVar - Create a global variable with internal /// linkage for use by the Objective-C runtime. /// @@ -2228,16 +2223,6 @@ llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD, return Method; } -/// GetFieldBaseOffset - return the field's byte offset. -uint64_t CGObjCCommonMac::GetFieldBaseOffset(const ObjCImplementationDecl *OI, - const llvm::StructLayout *Layout, - const FieldDecl *Field) { - // Is this a C struct? - if (!OI) - return Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(Field)); - return ComputeIvarBaseOffset(CGM, OI, cast(Field)); -} - llvm::GlobalVariable * CGObjCCommonMac::CreateMetadataVar(const std::string &Name, llvm::Constant *Init, @@ -2958,7 +2943,12 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, for (unsigned i = 0, e = RecFields.size(); i != e; ++i) { FieldDecl *Field = RecFields[i]; - unsigned FieldOffset = GetFieldBaseOffset(OI, Layout, Field); + uint64_t FieldOffset; + if (RD) + FieldOffset = + Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(Field)); + else + FieldOffset = ComputeIvarBaseOffset(CGM, OI, cast(Field)); // Skip over unnamed or bitfields if (!Field->getIdentifier() || Field->isBitField()) { -- 2.40.0