[clang] [clang] Extract in-memory module cache writes from `ASTWriter` (PR #190062)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 3 09:47:34 PDT 2026


================
@@ -1488,6 +1488,18 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance,
     ImportingInstance.getModuleCache().updateModuleTimestamp(ModuleFileName);
   }
 
+  // This isn't strictly necessary, but it's more efficient to extract the AST
+  // file (which may be wrapped in an object file) now rather than doing so
+  // repeatedly in the readers.
+  const PCHContainerReader &Rdr = ImportingInstance.getPCHContainerReader();
+  StringRef ExtractedBuffer = Rdr.ExtractPCH(*Buffer);
----------------
jansvoboda11 wrote:

Ah, that definitely makes sense! I think even re-layering this such that `ImportingInstance.compileModule()` returns the buffer as produced by `ASTWriter` would be nice. That way, the in-memory module cache can store it as-is, and we only need to wrap it for the module cache write, without the extra unwrap.

https://github.com/llvm/llvm-project/pull/190062


More information about the cfe-commits mailing list