]> granicus.if.org Git - clang/commitdiff
IRgen: Kill unused function and move the type match assert to after record dumping.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 19 Apr 2010 20:44:47 +0000 (20:44 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 19 Apr 2010 20:44:47 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101814 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGRecordLayoutBuilder.cpp

index 71dca504c59e1dd1225fbca9038371b35836235b..f056314221a8d52c9626d5e440d2b947be7da225 100644 (file)
@@ -93,10 +93,6 @@ private:
   /// AppendField - Appends a field with the given offset and type.
   void AppendField(uint64_t FieldOffsetInBytes, const llvm::Type *FieldTy);
 
-  /// AppendPadding - Appends enough padding bytes so that the total struct
-  /// size matches the alignment of the passed in type.
-  void AppendPadding(uint64_t FieldOffsetInBytes, const llvm::Type *FieldTy);
-
   /// AppendPadding - Appends enough padding bytes so that the total
   /// struct size is a multiple of the field alignment.
   void AppendPadding(uint64_t FieldOffsetInBytes, unsigned FieldAlignment);
@@ -481,12 +477,6 @@ void CGRecordLayoutBuilder::AppendField(uint64_t FieldOffsetInBytes,
   BitsAvailableInLastField = 0;
 }
 
-void
-CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes,
-                                     const llvm::Type *FieldTy) {
-  AppendPadding(FieldOffsetInBytes, getTypeAlignment(FieldTy));
-}
-
 void CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes,
                                           unsigned FieldAlignment) {
   assert(NextFieldOffsetInBytes <= FieldOffsetInBytes &&
@@ -562,9 +552,6 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) {
   const llvm::Type *Ty = llvm::StructType::get(getLLVMContext(),
                                                Builder.FieldTypes,
                                                Builder.Packed);
-  assert(getContext().getASTRecordLayout(D).getSize() / 8 ==
-         getTargetData().getTypeAllocSize(Ty) &&
-         "Type size mismatch!");
 
   CGRecordLayout *RL =
     new CGRecordLayout(Ty, Builder.ContainsPointerToDataMember);
@@ -577,6 +564,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) {
   for (unsigned i = 0, e = Builder.LLVMBitFields.size(); i != e; ++i)
     RL->BitFields.insert(Builder.LLVMBitFields[i]);
 
+  // Dump the layout, if requested.
   if (getContext().getLangOptions().DumpRecordLayouts) {
     llvm::errs() << "\n*** Dumping Record Layout\n";
     llvm::errs() << "Record: ";
@@ -585,6 +573,13 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) {
     RL->dump();
   }
 
+  // Verify that the computed LLVM struct size matches the AST layout size.
+  assert(getContext().getASTRecordLayout(D).getSize() / 8 ==
+         getTargetData().getTypeAllocSize(Ty) &&
+         "Type size mismatch!");
+
+  // FIXME: We should verify the individual field offsets here as well.
+
   return RL;
 }