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
llvm-svn: 318945
/// Changes options inside \p CI to use PCH from this preamble. Also remaps
/// main file to \p MainFileBuffer and updates \p VFS to ensure the preamble
/// is accessible.
+ /// For in-memory preambles, PrecompiledPreamble instance continues to own
+ /// the MemoryBuffer with the Preamble after this method returns. The caller
+ /// is reponsible for making sure the PrecompiledPreamble instance outlives
+ /// the compiler run and the AST that will be using the PCH.
void AddImplicitPreamble(CompilerInvocation &CI,
IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;
StringRef PCHPath = getInMemoryPreamblePath();
PreprocessorOpts.ImplicitPCHInclude = PCHPath;
- // FIMXE(ibiryukov): Preambles can be large. We should allow shared access
- // to the preamble data instead of copying it here.
- auto Buf = llvm::MemoryBuffer::getMemBufferCopy(Storage.asMemory().Data);
+ auto Buf = llvm::MemoryBuffer::getMemBuffer(Storage.asMemory().Data);
VFS = createVFSOverlayForPreamblePCH(PCHPath, std::move(Buf), VFS);
}
}