[PATCH] D40302: Avoid copying the data of in-memory preambles
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 24 05:13:10 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318945: Avoid copying the data of in-memory preambles (authored by ibiryukov).
Repository:
rL LLVM
https://reviews.llvm.org/D40302
Files:
cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===================================================================
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -699,9 +699,7 @@
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);
}
}
Index: cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
===================================================================
--- cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
+++ cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
@@ -98,6 +98,10 @@
/// 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40302.124170.patch
Type: text/x-patch
Size: 1664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171124/86658d15/attachment.bin>
More information about the cfe-commits
mailing list