diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-04-26 03:54:16 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-04-26 03:54:16 +0000 |
commit | c58d293a6f291913094d2af6d4d9ec85ccc0b92d (patch) | |
tree | 30447cf05fddf4f529b6fe92b60f2ff4547ab492 /llvm/runtime/libprofile/GCDAProfiling.c | |
parent | 72516899dbb2ec9ad2efc8710fb9a41b98cdfc6e (diff) | |
download | bcm5719-llvm-c58d293a6f291913094d2af6d4d9ec85ccc0b92d.tar.gz bcm5719-llvm-c58d293a6f291913094d2af6d4d9ec85ccc0b92d.zip |
Rename everything to follow LLVM style ... I think.
Add support for switch and indirectbr edges. This works by densely numbering
all blocks which have such terminators, and then separately numbering the
possible successors. The predecessors write down a number, the successor knows
its own number (as a ConstantInt) and sends that and the pointer to the number
the predecessor wrote down to the runtime, who looks up the counter in a
per-function table.
Coverage data should now be functional, but I haven't tested it on anything
other than my 2-file synthetic test program for coverage.
llvm-svn: 130186
Diffstat (limited to 'llvm/runtime/libprofile/GCDAProfiling.c')
-rw-r--r-- | llvm/runtime/libprofile/GCDAProfiling.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/llvm/runtime/libprofile/GCDAProfiling.c b/llvm/runtime/libprofile/GCDAProfiling.c index 0bd445c01f5..c8161d44b07 100644 --- a/llvm/runtime/libprofile/GCDAProfiling.c +++ b/llvm/runtime/libprofile/GCDAProfiling.c @@ -15,6 +15,9 @@ |* are only close enough that LCOV will happily parse them. Anything that lcov |* ignores is missing. |* +|* TODO: gcov is multi-process safe by having each exit open the existing file +|* and append to it. We'd like to achieve that and be thread-safe too. +|* \*===----------------------------------------------------------------------===*/ #include "llvm/Support/DataTypes.h" @@ -58,13 +61,33 @@ void llvm_gcda_start_file(const char *filename) { fwrite("adcg*404MVLL", 12, 1, output_file); #ifdef DEBUG_GCDAPROFILING - printf("[%s]\n", filename); + printf("llvmgcda: [%s]\n", filename); +#endif +} + +/* Given an array of pointers to counters (counters), increment the n-th one, + * where we're also given a pointer to n (predecessor). + */ +void llvm_gcda_increment_indirect_counter(uint32_t *predecessor, + uint64_t **counters) { + uint64_t *counter; + if (*predecessor == 0xffffffff) + return; + + /* Don't crash if the pred# is out of sync. This can happen due to threads, + or because of a TODO in GCOVProfiling.cpp buildEdgeLookupTable(). */ + if ((counter = counters[*predecessor])) + ++*counter; +#ifdef DEBUG_GCDAPROFILING + else + printf("llvmgcda: increment_indirect_counter counters=%x, pred=%u\n", + state_table_row, *predecessor); #endif } void llvm_gcda_emit_function(uint32_t ident) { #ifdef DEBUG_GCDAPROFILING - printf("function id=%x\n", ident); + printf("llvmgcda: function id=%x\n", ident); #endif /* function tag */ @@ -84,9 +107,9 @@ void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) { } #ifdef DEBUG_GCDAPROFILING - printf(" %u arcs\n", num_counters); + printf("llvmgcda: %u arcs\n", num_counters); for (i = 0; i < num_counters; ++i) { - printf(" %llu\n", (unsigned long long)counters[i]); + printf("llvmgcda: %llu\n", (unsigned long long)counters[i]); } #endif } @@ -98,6 +121,6 @@ void llvm_gcda_end_file() { output_file = NULL; #ifdef DEBUG_GCDAPROFILING - printf("-----\n"); + printf("llvmgcda: -----\n"); #endif } |