Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit e5081fa

Browse files
committedNov 24, 2017
Avoid copying the data of in-memory preambles
Summary: Preambles are large and we should avoid copying them. Reviewers: bkramer, klimek Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40302 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318945 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0a49d2d commit e5081fa

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎include/clang/Frontend/PrecompiledPreamble.h

+4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class PrecompiledPreamble {
9898
/// Changes options inside \p CI to use PCH from this preamble. Also remaps
9999
/// main file to \p MainFileBuffer and updates \p VFS to ensure the preamble
100100
/// is accessible.
101+
/// For in-memory preambles, PrecompiledPreamble instance continues to own
102+
/// the MemoryBuffer with the Preamble after this method returns. The caller
103+
/// is reponsible for making sure the PrecompiledPreamble instance outlives
104+
/// the compiler run and the AST that will be using the PCH.
101105
void AddImplicitPreamble(CompilerInvocation &CI,
102106
IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
103107
llvm::MemoryBuffer *MainFileBuffer) const;

‎lib/Frontend/PrecompiledPreamble.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,7 @@ void PrecompiledPreamble::setupPreambleStorage(
699699
StringRef PCHPath = getInMemoryPreamblePath();
700700
PreprocessorOpts.ImplicitPCHInclude = PCHPath;
701701

702-
// FIMXE(ibiryukov): Preambles can be large. We should allow shared access
703-
// to the preamble data instead of copying it here.
704-
auto Buf = llvm::MemoryBuffer::getMemBufferCopy(Storage.asMemory().Data);
702+
auto Buf = llvm::MemoryBuffer::getMemBuffer(Storage.asMemory().Data);
705703
VFS = createVFSOverlayForPreamblePCH(PCHPath, std::move(Buf), VFS);
706704
}
707705
}

0 commit comments

Comments
 (0)
This repository has been archived.