summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-04-26 03:54:16 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-04-26 03:54:16 +0000
commit1790c9cbb6714e81eab1412909a2320acaecc43b (patch)
tree457ac681b041c21814bdd1b96e884a60a5f6c5db /runtime
parentd88cac0a6e908a366f403b37725e765604bc15d3 (diff)
downloadllvm-1790c9cbb6714e81eab1412909a2320acaecc43b.tar.gz
llvm-1790c9cbb6714e81eab1412909a2320acaecc43b.tar.bz2
llvm-1790c9cbb6714e81eab1412909a2320acaecc43b.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130186 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r--runtime/libprofile/GCDAProfiling.c33
-rw-r--r--runtime/libprofile/libprofile.exports1
2 files changed, 29 insertions, 5 deletions
diff --git a/runtime/libprofile/GCDAProfiling.c b/runtime/libprofile/GCDAProfiling.c
index 0bd445c01f..c8161d44b0 100644
--- a/runtime/libprofile/GCDAProfiling.c
+++ b/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
}
diff --git a/runtime/libprofile/libprofile.exports b/runtime/libprofile/libprofile.exports
index aca563fc5c..2f25be6920 100644
--- a/runtime/libprofile/libprofile.exports
+++ b/runtime/libprofile/libprofile.exports
@@ -6,6 +6,7 @@ llvm_trace_basic_block
llvm_increment_path_count
llvm_decrement_path_count
llvm_gcda_start_file
+llvm_gcda_increment_indirect_counter
llvm_gcda_emit_function
llvm_gcda_emit_arcs
llvm_gcda_end_file