1 /*===-- EdgeProfiling.c - Support library for edge profiling --------------===*\
3 |* The LLVM Compiler Infrastructure
5 |* This file was developed by the LLVM research group and is distributed under
6 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
8 |*===----------------------------------------------------------------------===*|
10 |* This file implements the call back routines for the edge profiling
11 |* instrumentation pass. This should be used with the -insert-edge-profiling
14 \*===----------------------------------------------------------------------===*/
16 #include "Profiling.h"
19 static unsigned *ArrayStart;
20 static unsigned NumElements;
22 /* EdgeProfAtExitHandler - When the program exits, just write out the profiling
25 static void EdgeProfAtExitHandler() {
26 /* Note that if this were doing something more intellegent with the
27 instrumentation, that we could do some computation here to expand what we
28 collected into simple edge profiles. Since we directly count each edge, we
29 just write out all of the counters directly.
31 write_profiling_data(Edge, ArrayStart, NumElements);
35 /* llvm_start_edge_profiling - This is the main entry point of the edge
36 * profiling library. It is responsible for setting up the atexit handler.
38 int llvm_start_edge_profiling(int argc, const char **argv,
39 unsigned *arrayStart, unsigned numElements) {
40 int Ret = save_arguments(argc, argv);
41 ArrayStart = arrayStart;
42 NumElements = numElements;
43 atexit(EdgeProfAtExitHandler);