[PATCH] D46618: [sanitizer] Cleanup ReadFileToVector and ReadFileToBuffer

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 17:57:13 PDT 2018


morehouse added inline comments.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_common.h:647
+// This function is less I/O efficient than ReadFileToVector as it
+// may reread file multiple times to avoid avoid mmap during read
+// attempts.
----------------
Why is it implemented this way rather than copying over the bytes that have already been read?


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_file.cc:97
 bool ReadFileToBuffer(const char *file_name, char **buff, uptr *buff_size,
                       uptr *read_len, uptr max_len, error_t *errno_p) {
   *buff = nullptr;
----------------
This function looks much better than before, but since we're already modifying this maybe it would make sense to copy data over to the new mmapped region rather than rereading it.


Repository:
  rL LLVM

https://reviews.llvm.org/D46618





More information about the llvm-commits mailing list