[compiler-rt] r226312 - InstrProf: Optionally print an error when emitting profile data fails
Justin Bogner
mail at justinbogner.com
Fri Jan 16 12:10:57 PST 2015
Author: bogner
Date: Fri Jan 16 14:10:56 2015
New Revision: 226312
URL: http://llvm.org/viewvc/llvm-project?rev=226312&view=rev
Log:
InstrProf: Optionally print an error when emitting profile data fails
Debugging a missing profile is a bit painful right now. We can make
people's lives a bit easier by adding a knob to enable printing a
helpful error message for such failures.
Modified:
compiler-rt/trunk/lib/profile/InstrProfilingFile.c
Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=226312&r1=226311&r2=226312&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Fri Jan 16 14:10:56 2015
@@ -11,6 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/errno.h>
#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
@@ -175,7 +176,11 @@ int __llvm_profile_write_file(void) {
return -1;
/* Write the file. */
- return writeFileWithName(__llvm_profile_CurrentFilename);
+ int rc = writeFileWithName(__llvm_profile_CurrentFilename);
+ if (rc && getenv("LLVM_PROFILE_VERBOSE_ERRORS"))
+ fprintf(stderr, "LLVM Profile: Failed to write file \"%s\": %s\n",
+ __llvm_profile_CurrentFilename, strerror(errno));
+ return rc;
}
static void writeFileWithoutReturn(void) {
More information about the llvm-commits
mailing list