Don't allow a NULL-length file. Try to revert to the buffered version.
llvm-svn: 190359
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
index ea62e79..f80e062 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -206,6 +206,11 @@
   fseek(output_file, 0L, SEEK_END);
   file_size = ftell(output_file);
 
+  /* A size of 0 is invaild to `mmap'. Return a fail here, but don't issue an
+   * error message because it should "just work" for the user. */
+  if (file_size == 0)
+    return -1;
+
   write_buffer = mmap(0, file_size, PROT_READ | PROT_WRITE,
                       MAP_FILE | MAP_SHARED, fd, 0);
   if (write_buffer == (void *)-1) {