summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_debug.cpp9
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_debug.h4
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_init.c19
3 files changed, 31 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index 5d6d45d..621290f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -39,6 +39,8 @@
#include <llvm/Support/Host.h>
+#include <llvm/IR/Module.h>
+
#include <llvm/MC/MCDisassembler.h>
#include <llvm/MC/MCAsmInfo.h>
#include <llvm/MC/MCInst.h>
@@ -111,6 +113,13 @@ raw_debug_ostream::write_impl(const char *Ptr, size_t Size)
}
+extern "C" const char *
+lp_get_module_id(LLVMModuleRef module)
+{
+ return llvm::unwrap(module)->getModuleIdentifier().c_str();
+}
+
+
/**
* Same as LLVMDumpValue, but through our debugging channels.
*/
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
index 76c39af..321e09d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
@@ -76,6 +76,10 @@ lp_build_name(LLVMValueRef val, const char *format, ...)
}
+const char *
+lp_get_module_id(LLVMModuleRef module);
+
+
void
lp_debug_dump_value(LLVMValueRef value);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 7aebebb..8b8686d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -32,6 +32,7 @@
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
+#include "os/os_time.h"
#include "lp_bld.h"
#include "lp_bld_debug.h"
#include "lp_bld_misc.h"
@@ -498,6 +499,7 @@ gallivm_destroy(struct gallivm_state *gallivm)
/**
* Validate a function.
+ * Verification is only done with debug builds.
*/
void
gallivm_verify_function(struct gallivm_state *gallivm,
@@ -520,10 +522,15 @@ gallivm_verify_function(struct gallivm_state *gallivm,
}
+/**
+ * Compile a module.
+ * This does IR optimization on all functions in the module.
+ */
void
gallivm_compile_module(struct gallivm_state *gallivm)
{
LLVMValueRef func;
+ int64_t time_begin;
assert(!gallivm->compiled);
@@ -532,18 +539,28 @@ gallivm_compile_module(struct gallivm_state *gallivm)
gallivm->builder = NULL;
}
+ if (gallivm_debug & GALLIVM_DEBUG_PERF)
+ time_begin = os_time_get();
+
/* Run optimization passes */
LLVMInitializeFunctionPassManager(gallivm->passmgr);
func = LLVMGetFirstFunction(gallivm->module);
while (func) {
if (0) {
- debug_printf("optimizing %s...\n", LLVMGetValueName(func));
+ debug_printf("optimizing func %s...\n", LLVMGetValueName(func));
}
LLVMRunFunctionPassManager(gallivm->passmgr, func);
func = LLVMGetNextFunction(func);
}
LLVMFinalizeFunctionPassManager(gallivm->passmgr);
+ if (gallivm_debug & GALLIVM_DEBUG_PERF) {
+ int64_t time_end = os_time_get();
+ int time_msec = (int)(time_end - time_begin) / 1000;
+ debug_printf("optimizing module %s took %d msec\n",
+ lp_get_module_id(gallivm->module), time_msec);
+ }
+
/* Dump byte code to a file */
if (0) {
LLVMWriteBitcodeToFile(gallivm->module, "llvmpipe.bc");