gallivm: Fix include for LLVMAddPromoteMemoryToRegisterPass
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_init.c
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 #include "pipe/p_config.h"
30 #include "pipe/p_compiler.h"
31 #include "util/u_cpu_detect.h"
32 #include "util/u_debug.h"
33 #include "util/u_memory.h"
34 #include "util/simple_list.h"
35 #include "util/os_time.h"
36 #include "lp_bld.h"
37 #include "lp_bld_debug.h"
38 #include "lp_bld_misc.h"
39 #include "lp_bld_init.h"
40
41 #include <llvm-c/Analysis.h>
42 #include <llvm-c/Transforms/Scalar.h>
43 #if HAVE_LLVM >= 0x0700
44 #include <llvm-c/Transforms/Utils.h>
45 #endif
46 #include <llvm-c/BitWriter.h>
47
48
49 /* Only MCJIT is available as of LLVM SVN r216982 */
50 #if HAVE_LLVM >= 0x0306
51 # define USE_MCJIT 1
52 #elif defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
53 # define USE_MCJIT 1
54 #endif
55
56 #if defined(USE_MCJIT)
57 static const bool use_mcjit = USE_MCJIT;
58 #else
59 static bool use_mcjit = FALSE;
60 #endif
61
62
63 #ifdef DEBUG
64 unsigned gallivm_debug = 0;
65
66 static const struct debug_named_value lp_bld_debug_flags[] = {
67 { "tgsi", GALLIVM_DEBUG_TGSI, NULL },
68 { "ir", GALLIVM_DEBUG_IR, NULL },
69 { "asm", GALLIVM_DEBUG_ASM, NULL },
70 { "nopt", GALLIVM_DEBUG_NO_OPT, NULL },
71 { "perf", GALLIVM_DEBUG_PERF, NULL },
72 { "no_brilinear", GALLIVM_DEBUG_NO_BRILINEAR, NULL },
73 { "no_rho_approx", GALLIVM_DEBUG_NO_RHO_APPROX, NULL },
74 { "no_quad_lod", GALLIVM_DEBUG_NO_QUAD_LOD, NULL },
75 { "gc", GALLIVM_DEBUG_GC, NULL },
76 { "dumpbc", GALLIVM_DEBUG_DUMP_BC, NULL },
77 DEBUG_NAMED_VALUE_END
78 };
79
80 DEBUG_GET_ONCE_FLAGS_OPTION(gallivm_debug, "GALLIVM_DEBUG", lp_bld_debug_flags, 0)
81 #endif
82
83
84 static boolean gallivm_initialized = FALSE;
85
86 unsigned lp_native_vector_width;
87
88
89 /*
90 * Optimization values are:
91 * - 0: None (-O0)
92 * - 1: Less (-O1)
93 * - 2: Default (-O2, -Os)
94 * - 3: Aggressive (-O3)
95 *
96 * See also CodeGenOpt::Level in llvm/Target/TargetMachine.h
97 */
98 enum LLVM_CodeGenOpt_Level {
99 None, // -O0
100 Less, // -O1
101 Default, // -O2, -Os
102 Aggressive // -O3
103 };
104
105
106 /**
107 * Create the LLVM (optimization) pass manager and install
108 * relevant optimization passes.
109 * \return TRUE for success, FALSE for failure
110 */
111 static boolean
112 create_pass_manager(struct gallivm_state *gallivm)
113 {
114 assert(!gallivm->passmgr);
115 assert(gallivm->target);
116
117 gallivm->passmgr = LLVMCreateFunctionPassManagerForModule(gallivm->module);
118 if (!gallivm->passmgr)
119 return FALSE;
120 /*
121 * TODO: some per module pass manager with IPO passes might be helpful -
122 * the generated texture functions may benefit from inlining if they are
123 * simple, or constant propagation into them, etc.
124 */
125
126 #if HAVE_LLVM < 0x0309
127 // Old versions of LLVM get the DataLayout from the pass manager.
128 LLVMAddTargetData(gallivm->target, gallivm->passmgr);
129 #endif
130
131 {
132 char *td_str;
133 // New ones from the Module.
134 td_str = LLVMCopyStringRepOfTargetData(gallivm->target);
135 LLVMSetDataLayout(gallivm->module, td_str);
136 free(td_str);
137 }
138
139 if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) {
140 /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
141 * but there are more on SVN.
142 * TODO: Add more passes.
143 */
144 LLVMAddScalarReplAggregatesPass(gallivm->passmgr);
145 LLVMAddLICMPass(gallivm->passmgr);
146 LLVMAddCFGSimplificationPass(gallivm->passmgr);
147 LLVMAddReassociatePass(gallivm->passmgr);
148 LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
149 LLVMAddConstantPropagationPass(gallivm->passmgr);
150 LLVMAddInstructionCombiningPass(gallivm->passmgr);
151 LLVMAddGVNPass(gallivm->passmgr);
152 }
153 else {
154 /* We need at least this pass to prevent the backends to fail in
155 * unexpected ways.
156 */
157 LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
158 }
159
160 return TRUE;
161 }
162
163
164 /**
165 * Free gallivm object's LLVM allocations, but not any generated code
166 * nor the gallivm object itself.
167 */
168 void
169 gallivm_free_ir(struct gallivm_state *gallivm)
170 {
171 if (gallivm->passmgr) {
172 LLVMDisposePassManager(gallivm->passmgr);
173 }
174
175 if (gallivm->engine) {
176 /* This will already destroy any associated module */
177 LLVMDisposeExecutionEngine(gallivm->engine);
178 } else if (gallivm->module) {
179 LLVMDisposeModule(gallivm->module);
180 }
181
182 FREE(gallivm->module_name);
183
184 if (!use_mcjit) {
185 /* Don't free the TargetData, it's owned by the exec engine */
186 } else {
187 if (gallivm->target) {
188 LLVMDisposeTargetData(gallivm->target);
189 }
190 }
191
192 if (gallivm->builder)
193 LLVMDisposeBuilder(gallivm->builder);
194
195 /* The LLVMContext should be owned by the parent of gallivm. */
196
197 gallivm->engine = NULL;
198 gallivm->target = NULL;
199 gallivm->module = NULL;
200 gallivm->module_name = NULL;
201 gallivm->passmgr = NULL;
202 gallivm->context = NULL;
203 gallivm->builder = NULL;
204 }
205
206
207 /**
208 * Free LLVM-generated code. Should be done AFTER gallivm_free_ir().
209 */
210 static void
211 gallivm_free_code(struct gallivm_state *gallivm)
212 {
213 assert(!gallivm->module);
214 assert(!gallivm->engine);
215 lp_free_generated_code(gallivm->code);
216 gallivm->code = NULL;
217 lp_free_memory_manager(gallivm->memorymgr);
218 gallivm->memorymgr = NULL;
219 }
220
221
222 static boolean
223 init_gallivm_engine(struct gallivm_state *gallivm)
224 {
225 if (1) {
226 enum LLVM_CodeGenOpt_Level optlevel;
227 char *error = NULL;
228 int ret;
229
230 if (gallivm_debug & GALLIVM_DEBUG_NO_OPT) {
231 optlevel = None;
232 }
233 else {
234 optlevel = Default;
235 }
236
237 ret = lp_build_create_jit_compiler_for_module(&gallivm->engine,
238 &gallivm->code,
239 gallivm->module,
240 gallivm->memorymgr,
241 (unsigned) optlevel,
242 use_mcjit,
243 &error);
244 if (ret) {
245 _debug_printf("%s\n", error);
246 LLVMDisposeMessage(error);
247 goto fail;
248 }
249 }
250
251 if (!use_mcjit) {
252 gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine);
253 if (!gallivm->target)
254 goto fail;
255 } else {
256 if (0) {
257 /*
258 * Dump the data layout strings.
259 */
260
261 LLVMTargetDataRef target = LLVMGetExecutionEngineTargetData(gallivm->engine);
262 char *data_layout;
263 char *engine_data_layout;
264
265 data_layout = LLVMCopyStringRepOfTargetData(gallivm->target);
266 engine_data_layout = LLVMCopyStringRepOfTargetData(target);
267
268 if (1) {
269 debug_printf("module target data = %s\n", data_layout);
270 debug_printf("engine target data = %s\n", engine_data_layout);
271 }
272
273 free(data_layout);
274 free(engine_data_layout);
275 }
276 }
277
278 return TRUE;
279
280 fail:
281 return FALSE;
282 }
283
284
285 /**
286 * Allocate gallivm LLVM objects.
287 * \return TRUE for success, FALSE for failure
288 */
289 static boolean
290 init_gallivm_state(struct gallivm_state *gallivm, const char *name,
291 LLVMContextRef context)
292 {
293 assert(!gallivm->context);
294 assert(!gallivm->module);
295
296 if (!lp_build_init())
297 return FALSE;
298
299 gallivm->context = context;
300
301 if (!gallivm->context)
302 goto fail;
303
304 gallivm->module_name = NULL;
305 if (name) {
306 size_t size = strlen(name) + 1;
307 gallivm->module_name = MALLOC(size);
308 if (gallivm->module_name) {
309 memcpy(gallivm->module_name, name, size);
310 }
311 }
312
313 gallivm->module = LLVMModuleCreateWithNameInContext(name,
314 gallivm->context);
315 if (!gallivm->module)
316 goto fail;
317
318 gallivm->builder = LLVMCreateBuilderInContext(gallivm->context);
319 if (!gallivm->builder)
320 goto fail;
321
322 gallivm->memorymgr = lp_get_default_memory_manager();
323 if (!gallivm->memorymgr)
324 goto fail;
325
326 /* FIXME: MC-JIT only allows compiling one module at a time, and it must be
327 * complete when MC-JIT is created. So defer the MC-JIT engine creation for
328 * now.
329 */
330 if (!use_mcjit) {
331 if (!init_gallivm_engine(gallivm)) {
332 goto fail;
333 }
334 } else {
335 /*
336 * MC-JIT engine compiles the module immediately on creation, so we can't
337 * obtain the target data from it. Instead we create a target data layout
338 * from a string.
339 *
340 * The produced layout strings are not precisely the same, but should make
341 * no difference for the kind of optimization passes we run.
342 *
343 * For reference this is the layout string on x64:
344 *
345 * e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-f128:128:128-n8:16:32:64
346 *
347 * See also:
348 * - http://llvm.org/docs/LangRef.html#datalayout
349 */
350
351 {
352 const unsigned pointer_size = 8 * sizeof(void *);
353 char layout[512];
354 util_snprintf(layout, sizeof layout, "%c-p:%u:%u:%u-i64:64:64-a0:0:%u-s0:%u:%u",
355 #ifdef PIPE_ARCH_LITTLE_ENDIAN
356 'e', // little endian
357 #else
358 'E', // big endian
359 #endif
360 pointer_size, pointer_size, pointer_size, // pointer size, abi alignment, preferred alignment
361 pointer_size, // aggregate preferred alignment
362 pointer_size, pointer_size); // stack objects abi alignment, preferred alignment
363
364 gallivm->target = LLVMCreateTargetData(layout);
365 if (!gallivm->target) {
366 return FALSE;
367 }
368 }
369 }
370
371 if (!create_pass_manager(gallivm))
372 goto fail;
373
374 return TRUE;
375
376 fail:
377 gallivm_free_ir(gallivm);
378 gallivm_free_code(gallivm);
379 return FALSE;
380 }
381
382
383 boolean
384 lp_build_init(void)
385 {
386 if (gallivm_initialized)
387 return TRUE;
388
389
390 /* LLVMLinkIn* are no-ops at runtime. They just ensure the respective
391 * component is linked at buildtime, which is sufficient for its static
392 * constructors to be called at load time.
393 */
394 #if defined(USE_MCJIT)
395 # if USE_MCJIT
396 LLVMLinkInMCJIT();
397 # else
398 LLVMLinkInJIT();
399 # endif
400 #else
401 use_mcjit = debug_get_bool_option("GALLIVM_MCJIT", FALSE);
402 LLVMLinkInJIT();
403 LLVMLinkInMCJIT();
404 #endif
405
406 #ifdef DEBUG
407 gallivm_debug = debug_get_option_gallivm_debug();
408 #endif
409
410 lp_set_target_options();
411
412 util_cpu_detect();
413
414 /* For simulating less capable machines */
415 #ifdef DEBUG
416 if (debug_get_bool_option("LP_FORCE_SSE2", FALSE)) {
417 assert(util_cpu_caps.has_sse2);
418 util_cpu_caps.has_sse3 = 0;
419 util_cpu_caps.has_ssse3 = 0;
420 util_cpu_caps.has_sse4_1 = 0;
421 util_cpu_caps.has_sse4_2 = 0;
422 util_cpu_caps.has_avx = 0;
423 util_cpu_caps.has_avx2 = 0;
424 util_cpu_caps.has_f16c = 0;
425 util_cpu_caps.has_fma = 0;
426 }
427 #endif
428
429 /* AMD Bulldozer AVX's throughput is the same as SSE2; and because using
430 * 8-wide vector needs more floating ops than 4-wide (due to padding), it is
431 * actually more efficient to use 4-wide vectors on this processor.
432 *
433 * See also:
434 * - http://www.anandtech.com/show/4955/the-bulldozer-review-amd-fx8150-tested/2
435 */
436 if (util_cpu_caps.has_avx &&
437 util_cpu_caps.has_intel) {
438 lp_native_vector_width = 256;
439 } else {
440 /* Leave it at 128, even when no SIMD extensions are available.
441 * Really needs to be a multiple of 128 so can fit 4 floats.
442 */
443 lp_native_vector_width = 128;
444 }
445
446 lp_native_vector_width = debug_get_num_option("LP_NATIVE_VECTOR_WIDTH",
447 lp_native_vector_width);
448
449 if (lp_native_vector_width <= 128) {
450 /* Hide AVX support, as often LLVM AVX intrinsics are only guarded by
451 * "util_cpu_caps.has_avx" predicate, and lack the
452 * "lp_native_vector_width > 128" predicate. And also to ensure a more
453 * consistent behavior, allowing one to test SSE2 on AVX machines.
454 * XXX: should not play games with util_cpu_caps directly as it might
455 * get used for other things outside llvm too.
456 */
457 util_cpu_caps.has_avx = 0;
458 util_cpu_caps.has_avx2 = 0;
459 util_cpu_caps.has_f16c = 0;
460 util_cpu_caps.has_fma = 0;
461 }
462 if (HAVE_LLVM < 0x0304 || !use_mcjit) {
463 /* AVX2 support has only been tested with LLVM 3.4, and it requires
464 * MCJIT. */
465 util_cpu_caps.has_avx2 = 0;
466 }
467
468 #ifdef PIPE_ARCH_PPC_64
469 /* Set the NJ bit in VSCR to 0 so denormalized values are handled as
470 * specified by IEEE standard (PowerISA 2.06 - Section 6.3). This guarantees
471 * that some rounding and half-float to float handling does not round
472 * incorrectly to 0.
473 * XXX: should eventually follow same logic on all platforms.
474 * Right now denorms get explicitly disabled (but elsewhere) for x86,
475 * whereas ppc64 explicitly enables them...
476 */
477 if (util_cpu_caps.has_altivec) {
478 unsigned short mask[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
479 0xFFFF, 0xFFFF, 0xFFFE, 0xFFFF };
480 __asm (
481 "mfvscr %%v1\n"
482 "vand %0,%%v1,%0\n"
483 "mtvscr %0"
484 :
485 : "r" (*mask)
486 );
487 }
488 #endif
489
490 gallivm_initialized = TRUE;
491
492 return TRUE;
493 }
494
495
496
497 /**
498 * Create a new gallivm_state object.
499 */
500 struct gallivm_state *
501 gallivm_create(const char *name, LLVMContextRef context)
502 {
503 struct gallivm_state *gallivm;
504
505 gallivm = CALLOC_STRUCT(gallivm_state);
506 if (gallivm) {
507 if (!init_gallivm_state(gallivm, name, context)) {
508 FREE(gallivm);
509 gallivm = NULL;
510 }
511 }
512
513 return gallivm;
514 }
515
516
517 /**
518 * Destroy a gallivm_state object.
519 */
520 void
521 gallivm_destroy(struct gallivm_state *gallivm)
522 {
523 gallivm_free_ir(gallivm);
524 gallivm_free_code(gallivm);
525 FREE(gallivm);
526 }
527
528
529 /**
530 * Validate a function.
531 * Verification is only done with debug builds.
532 */
533 void
534 gallivm_verify_function(struct gallivm_state *gallivm,
535 LLVMValueRef func)
536 {
537 /* Verify the LLVM IR. If invalid, dump and abort */
538 #ifdef DEBUG
539 if (LLVMVerifyFunction(func, LLVMPrintMessageAction)) {
540 lp_debug_dump_value(func);
541 assert(0);
542 return;
543 }
544 #endif
545
546 if (gallivm_debug & GALLIVM_DEBUG_IR) {
547 /* Print the LLVM IR to stderr */
548 lp_debug_dump_value(func);
549 debug_printf("\n");
550 }
551 }
552
553
554 /**
555 * Compile a module.
556 * This does IR optimization on all functions in the module.
557 */
558 void
559 gallivm_compile_module(struct gallivm_state *gallivm)
560 {
561 LLVMValueRef func;
562 int64_t time_begin = 0;
563
564 assert(!gallivm->compiled);
565
566 if (gallivm->builder) {
567 LLVMDisposeBuilder(gallivm->builder);
568 gallivm->builder = NULL;
569 }
570
571 if (gallivm_debug & GALLIVM_DEBUG_PERF)
572 time_begin = os_time_get();
573
574 /* Run optimization passes */
575 LLVMInitializeFunctionPassManager(gallivm->passmgr);
576 func = LLVMGetFirstFunction(gallivm->module);
577 while (func) {
578 if (0) {
579 debug_printf("optimizing func %s...\n", LLVMGetValueName(func));
580 }
581
582 /* Disable frame pointer omission on debug/profile builds */
583 /* XXX: And workaround http://llvm.org/PR21435 */
584 #if HAVE_LLVM >= 0x0307 && \
585 (defined(DEBUG) || defined(PROFILE) || \
586 defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
587 LLVMAddTargetDependentFunctionAttr(func, "no-frame-pointer-elim", "true");
588 LLVMAddTargetDependentFunctionAttr(func, "no-frame-pointer-elim-non-leaf", "true");
589 #endif
590
591 LLVMRunFunctionPassManager(gallivm->passmgr, func);
592 func = LLVMGetNextFunction(func);
593 }
594 LLVMFinalizeFunctionPassManager(gallivm->passmgr);
595
596 if (gallivm_debug & GALLIVM_DEBUG_PERF) {
597 int64_t time_end = os_time_get();
598 int time_msec = (int)(time_end - time_begin) / 1000;
599 assert(gallivm->module_name);
600 debug_printf("optimizing module %s took %d msec\n",
601 gallivm->module_name, time_msec);
602 }
603
604 /* Dump byte code to a file */
605 if (gallivm_debug & GALLIVM_DEBUG_DUMP_BC) {
606 char filename[256];
607 assert(gallivm->module_name);
608 util_snprintf(filename, sizeof(filename), "ir_%s.bc", gallivm->module_name);
609 LLVMWriteBitcodeToFile(gallivm->module, filename);
610 debug_printf("%s written\n", filename);
611 debug_printf("Invoke as \"llc %s%s -o - %s\"\n",
612 (HAVE_LLVM >= 0x0305) ? "[-mcpu=<-mcpu option>] " : "",
613 "[-mattr=<-mattr option(s)>]",
614 filename);
615 }
616
617 if (use_mcjit) {
618 /* Setting the module's DataLayout to an empty string will cause the
619 * ExecutionEngine to copy to the DataLayout string from its target
620 * machine to the module. As of LLVM 3.8 the module and the execution
621 * engine are required to have the same DataLayout.
622 *
623 * We must make sure we do this after running the optimization passes,
624 * because those passes need a correct datalayout string. For example,
625 * if those optimization passes see an empty datalayout, they will assume
626 * this is a little endian target and will do optimizations that break big
627 * endian machines.
628 *
629 * TODO: This is just a temporary work-around. The correct solution is
630 * for gallivm_init_state() to create a TargetMachine and pull the
631 * DataLayout from there. Currently, the TargetMachine used by llvmpipe
632 * is being implicitly created by the EngineBuilder in
633 * lp_build_create_jit_compiler_for_module()
634 */
635 LLVMSetDataLayout(gallivm->module, "");
636 assert(!gallivm->engine);
637 if (!init_gallivm_engine(gallivm)) {
638 assert(0);
639 }
640 }
641 assert(gallivm->engine);
642
643 ++gallivm->compiled;
644
645 if (gallivm_debug & GALLIVM_DEBUG_ASM) {
646 LLVMValueRef llvm_func = LLVMGetFirstFunction(gallivm->module);
647
648 while (llvm_func) {
649 /*
650 * Need to filter out functions which don't have an implementation,
651 * such as the intrinsics. May not be sufficient in case of IPO?
652 * LLVMGetPointerToGlobal() will abort otherwise.
653 */
654 if (!LLVMIsDeclaration(llvm_func)) {
655 void *func_code = LLVMGetPointerToGlobal(gallivm->engine, llvm_func);
656 lp_disassemble(llvm_func, func_code);
657 }
658 llvm_func = LLVMGetNextFunction(llvm_func);
659 }
660 }
661
662 #if defined(PROFILE)
663 {
664 LLVMValueRef llvm_func = LLVMGetFirstFunction(gallivm->module);
665
666 while (llvm_func) {
667 if (!LLVMIsDeclaration(llvm_func)) {
668 void *func_code = LLVMGetPointerToGlobal(gallivm->engine, llvm_func);
669 lp_profile(llvm_func, func_code);
670 }
671 llvm_func = LLVMGetNextFunction(llvm_func);
672 }
673 }
674 #endif
675 }
676
677
678
679 func_pointer
680 gallivm_jit_function(struct gallivm_state *gallivm,
681 LLVMValueRef func)
682 {
683 void *code;
684 func_pointer jit_func;
685 int64_t time_begin = 0;
686
687 assert(gallivm->compiled);
688 assert(gallivm->engine);
689
690 if (gallivm_debug & GALLIVM_DEBUG_PERF)
691 time_begin = os_time_get();
692
693 code = LLVMGetPointerToGlobal(gallivm->engine, func);
694 assert(code);
695 jit_func = pointer_to_func(code);
696
697 if (gallivm_debug & GALLIVM_DEBUG_PERF) {
698 int64_t time_end = os_time_get();
699 int time_msec = (int)(time_end - time_begin) / 1000;
700 debug_printf(" jitting func %s took %d msec\n",
701 LLVMGetValueName(func), time_msec);
702 }
703
704 return jit_func;
705 }