summaryrefslogtreecommitdiff
path: root/runtime/libprofile/LineProfiling.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/libprofile/LineProfiling.c')
-rw-r--r--runtime/libprofile/LineProfiling.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/runtime/libprofile/LineProfiling.c b/runtime/libprofile/LineProfiling.c
new file mode 100644
index 0000000000..6e6fa196be
--- /dev/null
+++ b/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");
+}