summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/lib/profile/CMakeLists.txt2
-rw-r--r--compiler-rt/lib/profile/InstrProfilingExtras.c5
-rw-r--r--compiler-rt/lib/profile/InstrProfilingRuntime.cc28
-rw-r--r--compiler-rt/lib/profile/Makefile.mk4
-rw-r--r--compiler-rt/make/platform/clang_darwin.mk3
5 files changed, 34 insertions, 8 deletions
diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt
index 7de9c5e4b9b..949e174b40c 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -7,6 +7,7 @@ if(APPLE)
GCDAProfiling.c
InstrProfiling.c
InstrProfilingPlatformDarwin.c
+ InstrProfilingRuntime.cc
InstrProfilingExtras.c)
add_compiler_rt_osx_static_runtime(clang_rt.profile_osx
@@ -18,6 +19,7 @@ else()
GCDAProfiling.c
InstrProfiling.c
InstrProfilingPlatformOther.c
+ InstrProfilingRuntime.cc
InstrProfilingExtras.c)
foreach(arch ${PROFILE_SUPPORTED_ARCH})
diff --git a/compiler-rt/lib/profile/InstrProfilingExtras.c b/compiler-rt/lib/profile/InstrProfilingExtras.c
index 03399a3477f..45a7f8ce52c 100644
--- a/compiler-rt/lib/profile/InstrProfilingExtras.c
+++ b/compiler-rt/lib/profile/InstrProfilingExtras.c
@@ -9,7 +9,6 @@
#include "InstrProfiling.h"
-/*! \brief Write instrumentation data to the given file. */
void __llvm_pgo_write_file(const char *OutputName) {
/* TODO: Requires libc: move to separate translation unit. */
FILE *OutputFile;
@@ -26,7 +25,6 @@ void __llvm_pgo_write_file(const char *OutputName) {
fclose(OutputFile);
}
-/*! \brief Write instrumentation data to the default file. */
void __llvm_pgo_write_default_file() {
/* TODO: Requires libc: move to separate translation unit. */
const char *OutputName = getenv("LLVM_PROFILE_FILE");
@@ -35,9 +33,6 @@ void __llvm_pgo_write_default_file() {
__llvm_pgo_write_file(OutputName);
}
-/*!
- * \brief Register to write instrumentation data to the default file at exit.
- */
void __llvm_pgo_register_write_atexit() {
/* TODO: Requires libc: move to separate translation unit. */
static int HasBeenRegistered = 0;
diff --git a/compiler-rt/lib/profile/InstrProfilingRuntime.cc b/compiler-rt/lib/profile/InstrProfilingRuntime.cc
new file mode 100644
index 00000000000..e6ef4c94189
--- /dev/null
+++ b/compiler-rt/lib/profile/InstrProfilingRuntime.cc
@@ -0,0 +1,28 @@
+//===- InstrProfilingRuntime.cpp - PGO runtime initialization -------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+extern "C" {
+
+#include "InstrProfilingExtras.h"
+
+extern int __llvm_pgo_runtime;
+int __llvm_pgo_runtime;
+
+}
+
+namespace {
+
+class RegisterAtExit {
+public:
+ RegisterAtExit() { __llvm_pgo_register_write_atexit(); }
+};
+
+RegisterAtExit Registration;
+
+}
diff --git a/compiler-rt/lib/profile/Makefile.mk b/compiler-rt/lib/profile/Makefile.mk
index 7689c9a068c..dd3a36faf3b 100644
--- a/compiler-rt/lib/profile/Makefile.mk
+++ b/compiler-rt/lib/profile/Makefile.mk
@@ -10,8 +10,8 @@
ModuleName := profile
SubDirs :=
-Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file)))
-ObjNames := $(Sources:%.c=%.o)
+Sources := $(foreach file,$(wildcard $(Dir)/*.c $(Dir)/*.cc),$(notdir $(file)))
+ObjNames := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(Sources)))
Implementation := Generic
# FIXME: use automatic dependencies?
diff --git a/compiler-rt/make/platform/clang_darwin.mk b/compiler-rt/make/platform/clang_darwin.mk
index 0feb553417b..2fdf051bce9 100644
--- a/compiler-rt/make/platform/clang_darwin.mk
+++ b/compiler-rt/make/platform/clang_darwin.mk
@@ -223,7 +223,8 @@ FUNCTIONS.ios.x86_64h := $(FUNCTIONS.ios.x86_64)
FUNCTIONS.osx := mulosi4 mulodi4 muloti4
FUNCTIONS.profile_osx := GCDAProfiling InstrProfiling \
- InstrProfilingPlatformDarwin InstrProfilingExtras
+ InstrProfilingPlatformDarwin InstrProfilingRuntime \
+ InstrProfilingExtras
FUNCTIONS.profile_ios := $(FUNCTIONS.profile_osx)
FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(InterceptionFunctions) \
OpenPOWER on IntegriCloud