Mesa (master): gallivm: Register the JIT engine with oprofile on debug/ profile builds.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Jun 3 13:33:00 UTC 2010


Module: Mesa
Branch: master
Commit: 55948247ebd6b37b9ac1869992eb2f765dd62912
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=55948247ebd6b37b9ac1869992eb2f765dd62912

Author: José Fonseca <jfonseca at vmware.com>
Date:   Thu Jun  3 14:21:25 2010 +0100

gallivm: Register the JIT engine with oprofile on debug/profile builds.

---

 src/gallium/auxiliary/gallivm/lp_bld_init.c   |    8 ++++++++
 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp |   23 ++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 174e20e..0a690ea 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -75,6 +75,10 @@ enum LLVM_CodeGenOpt_Level {
 };
 
 
+extern void
+lp_register_oprofile_jit_event_listener(LLVMExecutionEngineRef EE);
+
+
 void
 lp_build_init(void)
 {
@@ -109,6 +113,10 @@ lp_build_init(void)
          LLVMDisposeMessage(error);
          assert(0);
       }
+
+#if defined(DEBUG) || defined(PROFILE)
+      lp_register_oprofile_jit_event_listener(lp_build_engine);
+#endif
    }
 
    if (!lp_build_target)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index db0ca60..f004c0a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -34,7 +34,10 @@
 #define __STDC_CONSTANT_MACROS
 #endif
 
-#include "llvm-c/Core.h"
+#include <llvm-c/Core.h>
+#include <llvm-c/ExecutionEngine.h>
+#include <llvm/ExecutionEngine/ExecutionEngine.h>
+#include <llvm/ExecutionEngine/JITEventListener.h>
 
 #include "pipe/p_config.h"
 #include "util/u_debug.h"
@@ -98,3 +101,21 @@ lp_debug_dump_value(LLVMValueRef value)
 
 
 #endif
+
+
+/**
+ * Register the engine with oprofile.
+ *
+ * This allows to see the LLVM IR function names in oprofile output.
+ *
+ * To actually work LLVM needs to be built with the --with-oprofile configure
+ * option.
+ *
+ * Also a oprofile:oprofile user:group is necessary. Which is not created by
+ * default on some distributions.
+ */
+extern "C" void
+lp_register_oprofile_jit_event_listener(LLVMExecutionEngineRef EE)
+{
+   llvm::unwrap(EE)->RegisterJITEventListener(llvm::createOProfileJITEventListener());
+}




More information about the mesa-commit mailing list