[cfe-commits] r125356 - in /cfe/trunk: include/clang/AST/RecordLayout.h lib/AST/RecordLayout.cpp lib/AST/RecordLayoutBuilder.cpp lib/CodeGen/CGObjCMac.cpp

Ken Dyck kd at kendyck.com
Thu Feb 10 18:20:09 PST 2011


Author: kjdyck
Date: Thu Feb 10 20:20:09 2011
New Revision: 125356

URL: http://llvm.org/viewvc/llvm-project?rev=125356&view=rev
Log:
Convert RecordLayout::DataSize to CharUnits from bits, eliminating two
unnecessary calls to RoundUpToAlignment. No changes to functionality
intended.


Modified:
    cfe/trunk/include/clang/AST/RecordLayout.h
    cfe/trunk/lib/AST/RecordLayout.cpp
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=125356&r1=125355&r2=125356&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Thu Feb 10 20:20:09 2011
@@ -36,8 +36,8 @@
   /// Size - Size of record in characters.
   CharUnits Size;
 
-  /// DataSize - Size of record in bits without tail padding.
-  uint64_t DataSize;
+  /// DataSize - Size of record in characters without tail padding.
+  CharUnits DataSize;
 
   /// FieldOffsets - Array of field offsets in bits.
   uint64_t *FieldOffsets;
@@ -83,13 +83,13 @@
   friend class ASTContext;
 
   ASTRecordLayout(const ASTContext &Ctx, CharUnits size, unsigned alignment,
-                  unsigned datasize, const uint64_t *fieldoffsets,
+                  CharUnits datasize, const uint64_t *fieldoffsets,
                   unsigned fieldcount);
 
   // Constructor for C++ records.
   typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
   ASTRecordLayout(const ASTContext &Ctx,
-                  CharUnits size, unsigned alignment, uint64_t datasize,
+                  CharUnits size, unsigned alignment, CharUnits datasize,
                   const uint64_t *fieldoffsets, unsigned fieldcount,
                   CharUnits nonvirtualsize, CharUnits nonvirtualalign,
                   CharUnits SizeOfLargestEmptySubobject,
@@ -123,8 +123,8 @@
   }
 
   /// getDataSize() - Get the record data size, which is the record size
-  /// without tail padding, in bits.
-  uint64_t getDataSize() const {
+  /// without tail padding, in characters.
+  CharUnits getDataSize() const {
     return DataSize;
   }
 

Modified: cfe/trunk/lib/AST/RecordLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayout.cpp?rev=125356&r1=125355&r2=125356&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayout.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayout.cpp Thu Feb 10 20:20:09 2011
@@ -28,7 +28,7 @@
 }
 
 ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
-                                 unsigned alignment, unsigned datasize,
+                                 unsigned alignment, CharUnits datasize,
                                  const uint64_t *fieldoffsets,
                                  unsigned fieldcount)
   : Size(size), DataSize(datasize), FieldOffsets(0), Alignment(alignment),
@@ -42,7 +42,7 @@
 // Constructor for C++ records.
 ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
                                  CharUnits size, unsigned alignment,
-                                 uint64_t datasize,
+                                 CharUnits datasize,
                                  const uint64_t *fieldoffsets,
                                  unsigned fieldcount,
                                  CharUnits nonvirtualsize,

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=125356&r1=125355&r2=125356&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Thu Feb 10 20:20:09 2011
@@ -1207,7 +1207,7 @@
 
     // We start laying out ivars not at the end of the superclass
     // structure, but at the next byte following the last field.
-    Size = llvm::RoundUpToAlignment(SL.getDataSize(), 8);
+    Size = Context.toBits(SL.getDataSize());
     DataSize = Size;
   }
 
@@ -1684,7 +1684,8 @@
     CharUnits RecordSize = toCharUnitsFromBits(Builder->Size);
     NewEntry =
       new (*this) ASTRecordLayout(*this, RecordSize, Builder->Alignment,
-                                  DataSize, Builder->FieldOffsets.data(),
+                                  toCharUnitsFromBits(DataSize), 
+                                  Builder->FieldOffsets.data(),
                                   Builder->FieldOffsets.size(),
                                   toCharUnitsFromBits(NonVirtualSize),
                                   toCharUnitsFromBits(NonVirtualAlign),
@@ -1700,7 +1701,7 @@
 
     NewEntry =
       new (*this) ASTRecordLayout(*this, RecordSize, Builder.Alignment,
-                                  Builder.Size,
+                                  toCharUnitsFromBits(Builder.Size),
                                   Builder.FieldOffsets.data(),
                                   Builder.FieldOffsets.size());
   }
@@ -1760,7 +1761,7 @@
 
   const ASTRecordLayout *NewEntry =
     new (*this) ASTRecordLayout(*this, RecordSize, Builder.Alignment,
-                                Builder.DataSize,
+                                toCharUnitsFromBits(Builder.DataSize),
                                 Builder.FieldOffsets.data(),
                                 Builder.FieldOffsets.size());
 
@@ -1857,7 +1858,7 @@
   }
 
   OS << "  sizeof=" << Layout.getSize().getQuantity();
-  OS << ", dsize=" << Layout.getDataSize() / 8;
+  OS << ", dsize=" << Layout.getDataSize().getQuantity();
   OS << ", align=" << Layout.getAlignment() / 8 << '\n';
   OS << "  nvsize=" << Layout.getNonVirtualSize().getQuantity();
   OS << ", nvalign=" << Layout.getNonVirtualAlign().getQuantity() << '\n';
@@ -1878,7 +1879,7 @@
   OS << "\nLayout: ";
   OS << "<ASTRecordLayout\n";
   OS << "  Size:" << toBits(Info.getSize()) << "\n";
-  OS << "  DataSize:" << Info.getDataSize() << "\n";
+  OS << "  DataSize:" << toBits(Info.getDataSize()) << "\n";
   OS << "  Alignment:" << Info.getAlignment() << "\n";
   OS << "  FieldOffsets: [";
   for (unsigned i = 0, e = Info.getFieldCount(); i != e; ++i) {

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=125356&r1=125355&r2=125356&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Feb 10 20:20:09 2011
@@ -4950,7 +4950,7 @@
     CGM.getContext().getASTObjCImplementationLayout(OID);
 
   // InstanceSize is really instance end.
-  InstanceSize = llvm::RoundUpToAlignment(RL.getDataSize(), 8) / 8;
+  InstanceSize = RL.getDataSize().getQuantity();
 
   // If there are no fields, the start is the same as the end.
   if (!RL.getFieldCount())





More information about the cfe-commits mailing list