mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129340 91177308-0d34-0410-b5e6-96231b3b80d8
38 lines
1.3 KiB
C
38 lines
1.3 KiB
C
/*===- 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");
|
|
}
|