summaryrefslogtreecommitdiffstats
path: root/llvm/runtime
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-04-12 01:06:09 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-04-12 01:06:09 +0000
commit9d60e373cfc5189f129a30c09189c9e8a50423f9 (patch)
treeac74d750426a15fcd116b7a37c584860d5d901ea /llvm/runtime
parent8e93666a710e8ffa9c762314c1f4f39ac7410f9f (diff)
downloadbcm5719-llvm-9d60e373cfc5189f129a30c09189c9e8a50423f9.tar.gz
bcm5719-llvm-9d60e373cfc5189f129a30c09189c9e8a50423f9.zip
Add support for line profiling. Very work-in-progress.
Use debug info in the IR to find the directory/file:line:col. Each time that location changes, bump a counter. Unlike the existing profiling system, we don't try to look at argv[], and thusly don't require main() to be present in the IR. This matches GCC's technique where you specify the profiling flag when producing each .o file. The runtime library is minimal, currently just calling printf at program shutdown time. The API is designed to make it possible to emit GCOV data later on. llvm-svn: 129340
Diffstat (limited to 'llvm/runtime')
-rw-r--r--llvm/runtime/libprofile/LineProfiling.c37
-rw-r--r--llvm/runtime/libprofile/libprofile.exports3
2 files changed, 40 insertions, 0 deletions
diff --git a/llvm/runtime/libprofile/LineProfiling.c b/llvm/runtime/libprofile/LineProfiling.c
new file mode 100644
index 00000000000..6e6fa196be1
--- /dev/null
+++ b/llvm/runtime/libprofile/LineProfiling.c
@@ -0,0 +1,37 @@
+/*===- LineProfiling.c - Support library for line profiling ---------------===*\
+|*
+|* The LLVM Compiler Infrastructure
+|*
+|* This file is distributed under the University of Illinois Open Source
+|* License. See LICENSE.TXT for details.
+|*
+|*===----------------------------------------------------------------------===*|
+|*
+|* This file implements the call back routines for the line profiling
+|* instrumentation pass. Link against this library when running code through
+|* the -insert-line-profiling LLVM pass.
+|*
+\*===----------------------------------------------------------------------===*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+
+/* A file in this case is a translation unit. Each .o file built with line
+ * profiling enabled will emit to a different file. Only one file may be
+ * started at a time.
+ */
+void llvm_prof_linectr_start_file(const char *orig_filename) {
+ printf("[%s]\n", orig_filename);
+}
+
+/* Emit data about a counter to the data file. */
+void llvm_prof_linectr_emit_counter(const char *dir, const char *file,
+ uint32_t line, uint32_t column,
+ int64_t *counter) {
+ printf("%s/%s:%u:%u %lu\n", dir, file, line, column, *counter);
+}
+
+void llvm_prof_linectr_end_file() {
+ printf("-----\n");
+}
diff --git a/llvm/runtime/libprofile/libprofile.exports b/llvm/runtime/libprofile/libprofile.exports
index b8057c7aac9..fb04ea3480d 100644
--- a/llvm/runtime/libprofile/libprofile.exports
+++ b/llvm/runtime/libprofile/libprofile.exports
@@ -5,3 +5,6 @@ llvm_start_basic_block_tracing
llvm_trace_basic_block
llvm_increment_path_count
llvm_decrement_path_count
+llvm_prof_linectr_start_file
+llvm_prof_linectr_emit_counter
+llvm_prof_linectr_end_file
OpenPOWER on IntegriCloud