[cfe-commits] r66448 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Fariborz Jahanian fjahanian at apple.com
Mon Mar 9 13:44:22 PDT 2009


Author: fjahanian
Date: Mon Mar  9 15:44:22 2009
New Revision: 66448

URL: http://llvm.org/viewvc/llvm-project?rev=66448&view=rev
Log:
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.

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=66448&r1=66447&r2=66448&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Mar  9 15:44:22 2009
@@ -1842,10 +1842,15 @@
 
 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 @@
   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()));





More information about the cfe-commits mailing list