From 717f7fa12a7a2ec076c138122bef9006b6b54487 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 25 May 2012 00:55:38 +0000 Subject: [PATCH] Don't call exit from a runtime. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157450 91177308-0d34-0410-b5e6-96231b3b80d8 --- runtime/libprofile/GCDAProfiling.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/libprofile/GCDAProfiling.c b/runtime/libprofile/GCDAProfiling.c index 3a48bb28265..568b2b0faa4 100644 --- a/runtime/libprofile/GCDAProfiling.c +++ b/runtime/libprofile/GCDAProfiling.c @@ -121,7 +121,7 @@ void llvm_gcda_start_file(const char *orig_filename) { fprintf(stderr, "LLVM profiling runtime: while opening '%s': ", cptr ? cptr + 1 : orig_filename); perror(""); - exit(1); + return; } } @@ -167,6 +167,7 @@ void llvm_gcda_emit_function(uint32_t ident, const char *function_name) { #ifdef DEBUG_GCDAPROFILING printf("llvmgcda: function id=%x\n", ident); #endif + if (!output_file) return; /* function tag */ fwrite("\0\0\0\1", 4, 1, output_file); @@ -179,7 +180,9 @@ void llvm_gcda_emit_function(uint32_t ident, const char *function_name) { void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) { uint32_t i; - /* counter #1 (arcs) tag */ + + /* Counter #1 (arcs) tag */ + if (!output_file) return; fwrite("\0\0\xa1\1", 4, 1, output_file); write_int32(num_counters * 2); for (i = 0; i < num_counters; ++i) { @@ -196,6 +199,7 @@ void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) { void llvm_gcda_end_file() { /* Write out EOF record. */ + if (!output_file) return; fwrite("\0\0\0\0\0\0\0\0", 8, 1, output_file); fclose(output_file); output_file = NULL;