gallivm: print out time for jitting functions with GALLIVM_DEBUG=perf
authorRoland Scheidegger <sroland@vmware.com>
Fri, 14 Oct 2016 03:37:34 +0000 (05:37 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 18 Oct 2016 23:44:59 +0000 (01:44 +0200)
Compilation to actual machine code can easily take as much time as the
optimization passes on the IR if not more, so print this out too.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_init.c

index 7114cde4384f30a264b66b90ac6cf92ade73a466..d1b2369f34ab38e01c53a912d3c20b239238256f 100644 (file)
@@ -659,13 +659,24 @@ gallivm_jit_function(struct gallivm_state *gallivm,
 {
    void *code;
    func_pointer jit_func;
+   int64_t time_begin = 0;
 
    assert(gallivm->compiled);
    assert(gallivm->engine);
 
+   if (gallivm_debug & GALLIVM_DEBUG_PERF)
+      time_begin = os_time_get();
+
    code = LLVMGetPointerToGlobal(gallivm->engine, func);
    assert(code);
    jit_func = pointer_to_func(code);
 
+   if (gallivm_debug & GALLIVM_DEBUG_PERF) {
+      int64_t time_end = os_time_get();
+      int time_msec = (int)(time_end - time_begin) / 1000;
+      debug_printf("   jitting func %s took %d msec\n",
+                   LLVMGetValueName(func), time_msec);
+   }
+
    return jit_func;
 }