diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-03 07:41:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-03 07:41:46 +0000 |
commit | 9be4f6d6c713f9abb8fb1900fa73b2dbc06b996b (patch) | |
tree | 27fc55cdd4accecbb74397cc165e01f860316bec /clang/lib/Basic/SourceManager.cpp | |
parent | ed8903e45a318ca8d18e1fe515550cbc6a185e66 (diff) | |
download | bcm5719-llvm-9be4f6d6c713f9abb8fb1900fa73b2dbc06b996b.tar.gz bcm5719-llvm-9be4f6d6c713f9abb8fb1900fa73b2dbc06b996b.zip |
reclaim my precious bit in FileInfo by ensuring that ContentCache objects
are 8-byte aligned.
llvm-svn: 63630
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 191b6155f09..6f78ee175c6 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -160,8 +160,12 @@ SourceManager::getOrCreateContentCache(const FileEntry *FileEnt) { ContentCache *&Entry = FileInfos[FileEnt]; if (Entry) return Entry; - // Nope, create a new Cache entry. - Entry = ContentCacheAlloc.Allocate<ContentCache>(); + // Nope, create a new Cache entry. Make sure it is at least 8-byte aligned + // so that FileInfo can use the low 3 bits of the pointer for its own + // nefarious purposes. + unsigned EntryAlign = llvm::AlignOf<ContentCache>::Alignment; + EntryAlign = std::max(8U, EntryAlign); + Entry = ContentCacheAlloc.Allocate<ContentCache>(1, EntryAlign); new (Entry) ContentCache(FileEnt); return Entry; } @@ -171,11 +175,12 @@ SourceManager::getOrCreateContentCache(const FileEntry *FileEnt) { /// memory buffer. This does no caching. const ContentCache* SourceManager::createMemBufferContentCache(const MemoryBuffer *Buffer) { - // Add a new ContentCache to the MemBufferInfos list and return it. We - // must default construct the object first that the instance actually - // stored within MemBufferInfos actually owns the Buffer, and not any - // temporary we would use in the call to "push_back". - ContentCache *Entry = ContentCacheAlloc.Allocate<ContentCache>(); + // Add a new ContentCache to the MemBufferInfos list and return it. Make sure + // it is at least 8-byte aligned so that FileInfo can use the low 3 bits of + // the pointer for its own nefarious purposes. + unsigned EntryAlign = llvm::AlignOf<ContentCache>::Alignment; + EntryAlign = std::max(8U, EntryAlign); + ContentCache *Entry = ContentCacheAlloc.Allocate<ContentCache>(1, EntryAlign); new (Entry) ContentCache(); MemBufferInfos.push_back(Entry); Entry->setBuffer(Buffer); |