From 4709975bfe6b884e3b2b62da7545b01a82239906 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 20 Mar 2014 03:23:10 +0000 Subject: PGO: Split out initialization of section bounds Currently we register instrumentation data at runtime to determine the bounds of the sections where the data lives. Soon we'll implement platform-specific linker magic to determine this at link time. Move this logic to a separate file, so that our build system can choose the correct platform-specific code. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204299 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/profile/InstrProfiling.c | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) (limited to 'lib/profile/InstrProfiling.c') diff --git a/lib/profile/InstrProfiling.c b/lib/profile/InstrProfiling.c index 41818ab8a..c897052d8 100644 --- a/lib/profile/InstrProfiling.c +++ b/lib/profile/InstrProfiling.c @@ -9,40 +9,6 @@ #include "InstrProfiling.h" -/* TODO: Calculate these with linker magic. */ -static const __llvm_pgo_data *First = NULL; -static const __llvm_pgo_data *Last = NULL; - -/*! - * \brief Register an instrumented function. - * - * Calls to this are emitted by clang with -fprofile-instr-generate. Such - * calls are only required (and only emitted) on targets where we haven't - * implemented linker magic to find the bounds of the section. - * - * For now, that's all targets. - */ -void __llvm_pgo_register_function(void *Data_) { - /* TODO: Only emit this function if we can't use linker magic. */ - const __llvm_pgo_data *Data = (__llvm_pgo_data*)Data_; - if (!First || Data < First) - First = Data; - if (!Last || Data >= Last) - Last = Data + 1; -} - -/*! \brief Get the first instrumentation record. */ -static const __llvm_pgo_data *getFirst() { - /* TODO: Use extern + linker magic instead of a static variable. */ - return First; -} - -/*! \brief Get the last instrumentation record. */ -static const __llvm_pgo_data *getLast() { - /* TODO: Use extern + linker magic instead of a static variable. */ - return Last; -} - /* TODO: void __llvm_pgo_get_size_for_buffer(void); */ static void writeFunction(FILE *OutputFile, const __llvm_pgo_data *Data) { @@ -64,6 +30,7 @@ void __llvm_pgo_write_buffer(FILE *OutputFile) { */ const __llvm_pgo_data *I, *E; - for (I = getFirst(), E = getLast(); I != E; ++I) + for (I = __llvm_pgo_data_begin(), E = __llvm_pgo_data_end(); + I != E; ++I) writeFunction(OutputFile, I); } -- cgit v1.2.3