diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-09 20:44:22 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-09 20:44:22 +0000 |
commit | a6681ae9bb1578b7a5be65eb34e22b026ecbe884 (patch) | |
tree | e2dec7873a8940fe4f229822a39c855aca819efb /lib/CodeGen | |
parent | db7bc5826f6dac055a08bd795e0cbd083ca87b2f (diff) |
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 25 |
1 files 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<FieldDecl *>(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())); |