[all-commits] [llvm/llvm-project] 429088: Support: Extract fs::resize_file_before_mapping_re...

Duncan P. N. Exon Smith via All-commits all-commits at lists.llvm.org
Thu Apr 8 16:31:03 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 429088b9e214b2f39f6063a6b3639560fc7db47b
      https://github.com/llvm/llvm-project/commit/429088b9e214b2f39f6063a6b3639560fc7db47b
  Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
  Date:   2021-04-08 (Thu, 08 Apr 2021)

  Changed paths:
    M llvm/include/llvm/Support/FileSystem.h
    M llvm/lib/Support/FileOutputBuffer.cpp
    M llvm/unittests/Support/Path.cpp

  Log Message:
  -----------
  Support: Extract fs::resize_file_before_mapping_readwrite from FileOutputBuffer

Add a variant of `fs::resize_file` for use immediately before opening a
file with `mapped_file_region::readwrite`. On Windows, `_chsize`
(`ftruncate`) is slow, but `CreateFileMapping` (`mmap`) automatically
extends the file so the call to `fs::resize_file` can be skipped.

This optimization was added to `FileOutputBuffer` in
da9bc2e56d5a5c6332a9def1a0065eb399182b93; this commit just extracts the
logic out and adds a unit test.

Differential Revision: https://reviews.llvm.org/D95490




More information about the All-commits mailing list