diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-03-19 21:01:19 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-03-19 21:01:19 +0000 |
commit | e647659d58d020644f7064b89a64e8d0bfbf585e (patch) | |
tree | 37c73ce7f0457f6364e7cf0eec5017caf165ce6f /compiler-rt/lib/profile | |
parent | 1c5d4c54a94339d3d0a0d2f840bacd405d12404f (diff) | |
download | bcm5719-llvm-e647659d58d020644f7064b89a64e8d0bfbf585e.tar.gz bcm5719-llvm-e647659d58d020644f7064b89a64e8d0bfbf585e.zip |
Add a way to register and execute "writeout" functions.
It may be prohibitively expensive to write out >1000 files at the same time. So
we would rather emit them serially. These functions allow the GCOV
implementation to register the functions that writeout the GCOV information per
compile unit. At exit, they are written.
<rdar://problem/12439551>
llvm-svn: 177436
Diffstat (limited to 'compiler-rt/lib/profile')
-rw-r--r-- | compiler-rt/lib/profile/GCDAProfiling.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c index ccaf01bbec1..bca25536755 100644 --- a/compiler-rt/lib/profile/GCDAProfiling.c +++ b/compiler-rt/lib/profile/GCDAProfiling.c @@ -48,6 +48,19 @@ typedef unsigned int uint64_t; static FILE *output_file = NULL; /* + * A list of functions to write out the data. + */ +typedef void (*writeout_fn)(); + +struct writeout_fn_node { + writeout_fn fn; + struct writeout_fn_node *next; +}; + +struct writeout_fn_node *writeout_fn_head = NULL; +struct writeout_fn_node *writeout_fn_tail = NULL; + +/* * A list of flush functions that our __gcov_flush() function should call. */ typedef void (*flush_fn)(); @@ -305,6 +318,38 @@ void llvm_gcda_end_file() { #endif } +void llvm_register_writeout_function(writeout_fn fn) { + struct writeout_fn_node *new_node = malloc(sizeof(struct writeout_fn_node)); + new_node->fn = fn; + new_node->next = NULL; + + if (!writeout_fn_head) { + writeout_fn_head = writeout_fn_tail = new_node; + } else { + writeout_fn_tail->next = new_node; + writeout_fn_tail = new_node; + } +} + +void __llvm_writeout_files() { + struct writeout_fn_node *curr = writeout_fn_head; + + while (curr) { + curr->fn(); + curr = curr->next; + } +} + +void llvm_delete_writeout_function_list() { + while (writeout_fn_head) { + struct writeout_fn_node *node = writeout_fn_head; + writeout_fn_head = writeout_fn_head->next; + free(node); + } + + writeout_fn_head = writeout_fn_tail = NULL; +} + void llvm_register_flush_function(flush_fn fn) { struct flush_fn_node *new_node = malloc(sizeof(struct flush_fn_node)); new_node->fn = fn; |