From 1727c6aab34012f0cefc8a3f29ede5f1f718c832 Mon Sep 17 00:00:00 2001 From: Michael Spencer Date: Wed, 10 Jun 2020 14:37:03 -0600 Subject: [clang] Use IsVolatile=true and RequiresNullTerminator=false for PCMs This change got missed while upstreaming https://reviews.llvm.org/D77772. This is the part of that change that actually passes the correct arguments when opening a PCM. The test didn't catch this because it starts at the `MemoryBuffer::getOpenFile` level. It's not really possible to test `ModuleManager::addModule` itself to verify how the file was opened. --- clang/lib/Serialization/ModuleManager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'clang/lib/Serialization/ModuleManager.cpp') diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 2656220..a42ed2f 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -185,7 +185,14 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, Buf = llvm::MemoryBuffer::getSTDIN(); } else { // Get a buffer of the file and close the file descriptor when done. - Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/false); + // The file is volatile because in a parallel build we expect multiple + // compiler processes to use the same module file rebuilding it if needed. + // + // RequiresNullTerminator is false because module files don't need it, and + // this allows the file to still be mmapped. + Buf = FileMgr.getBufferForFile(NewModule->File, + /*IsVolatile=*/true, + /*RequiresNullTerminator=*/false); } if (!Buf) { -- cgit v1.1