[cfe-commits] r147626 - /cfe/trunk/lib/AST/DeclBase.cpp

Douglas Gregor dgregor at apple.com
Thu Jan 5 15:49:36 PST 2012


Author: dgregor
Date: Thu Jan  5 17:49:36 2012
New Revision: 147626

URL: http://llvm.org/viewvc/llvm-project?rev=147626&view=rev
Log:
Always allocate an extra 8 bytes for a deserialized declaration, since
some code in Clang expects 8-byte alignment of declarations.

Modified:
    cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=147626&r1=147625&r2=147626&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Jan  5 17:49:36 2012
@@ -44,14 +44,11 @@
 void *Decl::AllocateDeserializedDecl(const ASTContext &Context, 
                                      unsigned ID,
                                      unsigned Size) {
-  // Allocate an extra pointer's worth of storage, which ensures that 
-  //   (1) We have enough storage to stash the global declaration ID, and
-  //   (2) We maintain pointer alignment.
-  //
-  // Note that this wastes 4 bytes on x86-64, which we'll undoubtedly end up
-  // finding a use for later.
-  void *Start = Context.Allocate(Size + sizeof(void*));
-  void *Result = (char*)Start + sizeof(void*);
+  // Allocate an extra 8 bytes worth of storage, which ensures that the
+  // resulting pointer will still be 8-byte aligned. At present, we're only
+  // using the latter 4 bytes of this storage.
+  void *Start = Context.Allocate(Size + 8);
+  void *Result = (char*)Start + 8;
   
   // Store the global declaration ID 
   unsigned *IDPtr = (unsigned*)Result - 1;





More information about the cfe-commits mailing list