[PATCH] D28010: FileOutputBuffer: support non-mmap'able file.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 07:06:21 PST 2016


> +// Represents a non-memory-mapped file. We need this class
> +// because not all files are mmap'able. For example, /dev/null
> +// is not mmap'able.

The comment is a bit confusing. The issue is that with the old code if
you tried to "-o /dev/null", we would not try to mmap /dev/null. We
would try to mmap a temp file and move it to /dev/null.

Maybe the best way to do this is
* Check the file type as you did.
* Remember the result in a member variable.
* If it is regular, use fs::createUniqueFile.
* If it is not, use fs::createTemporaryFile, which can also be mmaped.
* In commit, do a move if the target is regular or write the contents if
  it is not.

That should reduce the code difference between the two cases.

Cheers,
Rafael


More information about the llvm-commits mailing list