6e6fa196be1026cf9c294af451eea532a683ffe6
[oota-llvm.git] / runtime / libprofile / LineProfiling.c
1 /*===- LineProfiling.c - Support library for line profiling ---------------===*\
2 |*
3 |*                     The LLVM Compiler Infrastructure
4 |*
5 |* This file is distributed under the University of Illinois Open Source
6 |* License. See LICENSE.TXT for details.
7 |* 
8 |*===----------------------------------------------------------------------===*|
9 |* 
10 |* This file implements the call back routines for the line profiling
11 |* instrumentation pass. Link against this library when running code through
12 |* the -insert-line-profiling LLVM pass.
13 |*
14 \*===----------------------------------------------------------------------===*/
15
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <stdint.h>
19
20 /* A file in this case is a translation unit. Each .o file built with line
21  * profiling enabled will emit to a different file. Only one file may be
22  * started at a time.
23  */
24 void llvm_prof_linectr_start_file(const char *orig_filename) {
25   printf("[%s]\n", orig_filename);
26 }
27
28 /* Emit data about a counter to the data file. */
29 void llvm_prof_linectr_emit_counter(const char *dir, const char *file,
30                                     uint32_t line, uint32_t column,
31                                     int64_t *counter) {
32   printf("%s/%s:%u:%u %lu\n", dir, file, line, column, *counter);
33 }
34
35 void llvm_prof_linectr_end_file() {
36   printf("-----\n");
37 }