From a6681ae9bb1578b7a5be65eb34e22b026ecbe884 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 9 Mar 2009 20:44:22 +0000 Subject: [PATCH] More fix for bitfield ivar meta-data and code gen accessing it. Now, we can actually execute dejagnu test with bitfield ivars in non-fragile abi mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66448 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGObjCMac.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 9922d82fc2..5ae32e8737 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1842,10 +1842,15 @@ llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD, uint64_t CGObjCCommonMac::GetIvarBaseOffset(const llvm::StructLayout *Layout, FieldDecl *Field) { - return Field->isBitField() - ? CGM.getTypes().getLLVMFieldNo(Field) - : Layout->getElementOffset( - CGM.getTypes().getLLVMFieldNo(Field)); + if (!Field->isBitField()) + return Layout->getElementOffset( + CGM.getTypes().getLLVMFieldNo(Field)); + // FIXME. Must be a better way of getting a bitfield base offset. + uint64_t offset = CGM.getTypes().getLLVMFieldNo(Field); + const llvm::Type *Ty = CGM.getTypes().ConvertTypeForMemRecursive(Field->getType()); + uint64_t size = CGM.getTypes().getTargetData().getTypePaddedSizeInBits(Ty); + offset = (offset*size)/8; + return offset; } llvm::GlobalVariable * @@ -4485,10 +4490,14 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar( llvm::Type *ptrIvarTy = llvm::PointerType::getUnqual(IvarTy); V = CGF.Builder.CreateBitCast(V, ptrIvarTy); - if (Ivar->isBitField()) - return CGF.EmitLValueForBitfield(V, const_cast(Field), - CVRQualifiers); - + if (Ivar->isBitField()) { + CodeGenTypes::BitFieldInfo bitFieldInfo = + CGM.getTypes().getBitFieldInfo(Field); + return LValue::MakeBitfield(V, bitFieldInfo.Begin, bitFieldInfo.Size, + Field->getType()->isSignedIntegerType(), + Field->getType().getCVRQualifiers()|CVRQualifiers); + } + LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers, CGM.getContext().getObjCGCAttrKind(Ivar->getType())); -- 2.40.0