gallivm: add early cse pass
[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 /*
141 * TODO: Evaluate passes some more - keeping in mind
142 * both quality of generated code and compile times.
143 */
144 LLVMAddScalarReplAggregatesPass(gallivm->passmgr);
145 LLVMAddEarlyCSEPass(gallivm->passmgr);
146 LLVMAddCFGSimplificationPass(gallivm->passmgr);
147 LLVMAddLICMPass(gallivm->passmgr);
148 LLVMAddReassociatePass(gallivm->passmgr);
149 LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
150 LLVMAddConstantPropagationPass(gallivm->passmgr);
151 LLVMAddInstructionCombiningPass(gallivm->passmgr);
152 LLVMAddGVNPass(gallivm->passmgr);
153 }
154 else {
155 /* We need at least this pass to prevent the backends to fail in
156 * unexpected ways.
157 */
158 LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr);
159 }
160
161 return TRUE;
162 }
163
164
165 /**
166 * Free gallivm object's LLVM allocations, but not any generated code
167 * nor the gallivm object itself.
168 */
169 void
170 gallivm_free_ir(struct gallivm_state *gallivm)
171 {
172 if (gallivm->passmgr) {
173 LLVMDisposePassManager(gallivm->passmgr);
174 }
175
176 if (gallivm->engine) {
177 /* This will already destroy any associated module */
178 LLVMDisposeExecutionEngine(gallivm->engine);
179 } else if (gallivm->module) {
180 LLVMDisposeModule(gallivm->module);
181 }
182
183 FREE(gallivm->module_name);
184
185 if (!use_mcjit) {
186 /* Don't free the TargetData, it's owned by the exec engine */
187 } else {
188 if (gallivm->target) {
189 LLVMDisposeTargetData(gallivm->target);
190 }
191 }
192
193 if (gallivm->builder)
194 LLVMDisposeBuilder(gallivm->builder);
195
196 /* The LLVMContext should be owned by the parent of gallivm. */
197
198 gallivm->engine = NULL;
199 gallivm->target = NULL;
200 gallivm->module = NULL;
201 gallivm->module_name = NULL;
202 gallivm->passmgr = NULL;
203 gallivm->context = NULL;
204 gallivm->builder = NULL;
205 }
206
207
208 /**
209 * Free LLVM-generated code. Should be done AFTER gallivm_free_ir().
210 */
211 static void
212 gallivm_free_code(struct gallivm_state *gallivm)
213 {
214 assert(!gallivm->module);
215 assert(!gallivm->engine);
216 lp_free_generated_code(gallivm->code);
217 gallivm->code = NULL;
218 lp_free_memory_manager(gallivm->memorymgr);
219 gallivm->memorymgr = NULL;
220 }
221
222
223 static boolean
224 init_gallivm_engine(struct gallivm_state *gallivm)
225 {
226 if (1) {
227 enum LLVM_CodeGenOpt_Level optlevel;
228 char *error = NULL;
229 int ret;
230
231 if (gallivm_debug & GALLIVM_DEBUG_NO_OPT) {
232 optlevel = None;
233 }
234 else {
235 optlevel = Default;
236 }
237
238 ret = lp_build_create_jit_compiler_for_module(&gallivm->engine,
239 &gallivm->code,
240 gallivm->module,
241 gallivm->memorymgr,
242 (unsigned) optlevel,
243 use_mcjit,
244 &error);
245 if (ret) {
246 _debug_printf("%s\n", error);
247 LLVMDisposeMessage(error);
248 goto fail;
249 }
250 }
251
252 if (!use_mcjit) {
253 gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine);
254 if (!gallivm->target)
255 goto fail;
256 } else {
257 if (0) {
258 /*
259 * Dump the data layout strings.
260 */
261
262 LLVMTargetDataRef target = LLVMGetExecutionEngineTargetData(gallivm->engine);
263 char *data_layout;
264 char *engine_data_layout;
265
266 data_layout = LLVMCopyStringRepOfTargetData(gallivm->target);
267 engine_data_layout = LLVMCopyStringRepOfTargetData(target);
268
269 if (1) {
270 debug_printf("module target data = %s\n", data_layout);
271 debug_printf("engine target data = %s\n", engine_data_layout);
272 }
273
274 free(data_layout);
275 free(engine_data_layout);
276 }
277 }
278
279 return TRUE;
280
281 fail:
282 return FALSE;
283 }
284
285
286 /**
287 * Allocate gallivm LLVM objects.
288 * \return TRUE for success, FALSE for failure
289 */
290 static boolean
291 init_gallivm_state(struct gallivm_state *gallivm, const char *name,
292 LLVMContextRef context)
293 {
294 assert(!gallivm->context);
295 assert(!gallivm->module);
296
297 if (!lp_build_init())
298 return FALSE;
299
300 gallivm->context = context;
301
302 if (!gallivm->context)
303 goto fail;
304
305 gallivm->module_name = NULL;
306 if (name) {
307 size_t size = strlen(name) + 1;
308 gallivm->module_name = MALLOC(size);
309 if (gallivm->module_name) {
310 memcpy(gallivm->module_name, name, size);
311 }
312 }
313
314 gallivm->module = LLVMModuleCreateWithNameInContext(name,
315 gallivm->context);
316 if (!gallivm->module)
317 goto fail;
318
319 gallivm->builder = LLVMCreateBuilderInContext(gallivm->context);
320 if (!gallivm->builder)
321 goto fail;
322
323 gallivm->memorymgr = lp_get_default_memory_manager();
324 if (!gallivm->memorymgr)
325 goto fail;
326
327 /* FIXME: MC-JIT only allows compiling one module at a time, and it must be
328 * complete when MC-JIT is created. So defer the MC-JIT engine creation for
329 * now.
330 */
331 if (!use_mcjit) {
332 if (!init_gallivm_engine(gallivm)) {
333 goto fail;
334 }
335 } else {
336 /*
337 * MC-JIT engine compiles the module immediately on creation, so we can't
338 * obtain the target data from it. Instead we create a target data layout
339 * from a string.
340 *
341 * The produced layout strings are not precisely the same, but should make
342 * no difference for the kind of optimization passes we run.
343 *
344 * For reference this is the layout string on x64:
345 *
346 * 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
347 *
348 * See also:
349 * - http://llvm.org/docs/LangRef.html#datalayout
350 */
351
352 {
353 const unsigned pointer_size = 8 * sizeof(void *);
354 char layout[512];
355 util_snprintf(layout, sizeof layout, "%c-p:%u:%u:%u-i64:64:64-a0:0:%u-s0:%u:%u",
356 #ifdef PIPE_ARCH_LITTLE_ENDIAN
357 'e', // little endian
358 #else
359 'E', // big endian
360 #endif
361 pointer_size, pointer_size, pointer_size, // pointer size, abi alignment, preferred alignment
362 pointer_size, // aggregate preferred alignment
363 pointer_size, pointer_size); // stack objects abi alignment, preferred alignment
364
365 gallivm->target = LLVMCreateTargetData(layout);
366 if (!gallivm->target) {
367 return FALSE;
368 }
369 }
370 }
371
372 if (!create_pass_manager(gallivm))
373 goto fail;
374
375 return TRUE;
376
377 fail:
378 gallivm_free_ir(gallivm);
379 gallivm_free_code(gallivm);
380 return FALSE;
381 }
382
383
384 boolean
385 lp_build_init(void)
386 {
387 if (gallivm_initialized)
388 return TRUE;
389
390
391 /* LLVMLinkIn* are no-ops at runtime. They just ensure the respective
392 * component is linked at buildtime, which is sufficient for its static
393 * constructors to be called at load time.
394 */
395 #if defined(USE_MCJIT)
396 # if USE_MCJIT
397 LLVMLinkInMCJIT();
398 # else
399 LLVMLinkInJIT();
400 # endif
401 #else
402 use_mcjit = debug_get_bool_option("GALLIVM_MCJIT", FALSE);
403 LLVMLinkInJIT();
404 LLVMLinkInMCJIT();
405 #endif
406
407 #ifdef DEBUG
408 gallivm_debug = debug_get_option_gallivm_debug();
409 #endif
410
411 lp_set_target_options();
412
413 util_cpu_detect();
414
415 /* For simulating less capable machines */
416 #ifdef DEBUG
417 if (debug_get_bool_option("LP_FORCE_SSE2", FALSE)) {
418 assert(util_cpu_caps.has_sse2);
419 util_cpu_caps.has_sse3 = 0;
420 util_cpu_caps.has_ssse3 = 0;
421 util_cpu_caps.has_sse4_1 = 0;
422 util_cpu_caps.has_sse4_2 = 0;
423 util_cpu_caps.has_avx = 0;
424 util_cpu_caps.has_avx2 = 0;
425 util_cpu_caps.has_f16c = 0;
426 util_cpu_caps.has_fma = 0;
427 }
428 #endif
429
430 /* AMD Bulldozer AVX's throughput is the same as SSE2; and because using
431 * 8-wide vector needs more floating ops than 4-wide (due to padding), it is
432 * actually more efficient to use 4-wide vectors on this processor.
433 *
434 * See also:
435 * - http://www.anandtech.com/show/4955/the-bulldozer-review-amd-fx8150-tested/2
436 */
437 if (util_cpu_caps.has_avx &&
438 util_cpu_caps.has_intel) {
439 lp_native_vector_width = 256;
440 } else {
441 /* Leave it at 128, even when no SIMD extensions are available.
442 * Really needs to be a multiple of 128 so can fit 4 floats.
443 */
444 lp_native_vector_width = 128;
445 }
446
447 lp_native_vector_width = debug_get_num_option("LP_NATIVE_VECTOR_WIDTH",
448 lp_native_vector_width);
449
450 if (lp_native_vector_width <= 128) {
451 /* Hide AVX support, as often LLVM AVX intrinsics are only guarded by
452 * "util_cpu_caps.has_avx" predicate, and lack the
453 * "lp_native_vector_width > 128" predicate. And also to ensure a more
454 * consistent behavior, allowing one to test SSE2 on AVX machines.
455 * XXX: should not play games with util_cpu_caps directly as it might
456 * get used for other things outside llvm too.
457 */
458 util_cpu_caps.has_avx = 0;
459 util_cpu_caps.has_avx2 = 0;
460 util_cpu_caps.has_f16c = 0;
461 util_cpu_caps.has_fma = 0;
462 }
463 if (HAVE_LLVM < 0x0304 || !use_mcjit) {
464 /* AVX2 support has only been tested with LLVM 3.4, and it requires
465 * MCJIT. */
466 util_cpu_caps.has_avx2 = 0;
467 }
468
469 #ifdef PIPE_ARCH_PPC_64
470 /* Set the NJ bit in VSCR to 0 so denormalized values are handled as
471 * specified by IEEE standard (PowerISA 2.06 - Section 6.3). This guarantees
472 * that some rounding and half-float to float handling does not round
473 * incorrectly to 0.
474 * XXX: should eventually follow same logic on all platforms.
475 * Right now denorms get explicitly disabled (but elsewhere) for x86,
476 * whereas ppc64 explicitly enables them...
477 */
478 if (util_cpu_caps.has_altivec) {
479 unsigned short mask[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
480 0xFFFF, 0xFFFF, 0xFFFE, 0xFFFF };
481 __asm (
482 "mfvscr %%v1\n"
483 "vand %0,%%v1,%0\n"
484 "mtvscr %0"
485 :
486 : "r" (*mask)
487 );
488 }
489 #endif
490
491 gallivm_initialized = TRUE;
492
493 return TRUE;
494 }
495
496
497
498 /**
499 * Create a new gallivm_state object.
500 */
501 struct gallivm_state *
502 gallivm_create(const char *name, LLVMContextRef context)
503 {
504 struct gallivm_state *gallivm;
505
506 gallivm = CALLOC_STRUCT(gallivm_state);
507 if (gallivm) {
508 if (!init_gallivm_state(gallivm, name, context)) {
509 FREE(gallivm);
510 gallivm = NULL;
511 }
512 }
513
514 return gallivm;
515 }
516
517
518 /**
519 * Destroy a gallivm_state object.
520 */
521 void
522 gallivm_destroy(struct gallivm_state *gallivm)
523 {
524 gallivm_free_ir(gallivm);
525 gallivm_free_code(gallivm);
526 FREE(gallivm);
527 }
528
529
530 /**
531 * Validate a function.
532 * Verification is only done with debug builds.
533 */
534 void
535 gallivm_verify_function(struct gallivm_state *gallivm,
536 LLVMValueRef func)
537 {
538 /* Verify the LLVM IR. If invalid, dump and abort */
539 #ifdef DEBUG
540 if (LLVMVerifyFunction(func, LLVMPrintMessageAction)) {
541 lp_debug_dump_value(func);
542 assert(0);
543 return;
544 }
545 #endif
546
547 if (gallivm_debug & GALLIVM_DEBUG_IR) {
548 /* Print the LLVM IR to stderr */
549 lp_debug_dump_value(func);
550 debug_printf("\n");
551 }
552 }
553
554
555 /**
556 * Compile a module.
557 * This does IR optimization on all functions in the module.
558 */
559 void
560 gallivm_compile_module(struct gallivm_state *gallivm)
561 {
562 LLVMValueRef func;
563 int64_t time_begin = 0;
564
565 assert(!gallivm->compiled);
566
567 if (gallivm->builder) {
568 LLVMDisposeBuilder(gallivm->builder);
569 gallivm->builder = NULL;
570 }
571
572 if (gallivm_debug & GALLIVM_DEBUG_PERF)
573 time_begin = os_time_get();
574
575 /* Run optimization passes */
576 LLVMInitializeFunctionPassManager(gallivm->passmgr);
577 func = LLVMGetFirstFunction(gallivm->module);
578 while (func) {
579 if (0) {
580 debug_printf("optimizing func %s...\n", LLVMGetValueName(func));
581 }
582
583 /* Disable frame pointer omission on debug/profile builds */
584 /* XXX: And workaround http://llvm.org/PR21435 */
585 #if HAVE_LLVM >= 0x0307 && \
586 (defined(DEBUG) || defined(PROFILE) || \
587 defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
588 LLVMAddTargetDependentFunctionAttr(func, "no-frame-pointer-elim", "true");
589 LLVMAddTargetDependentFunctionAttr(func, "no-frame-pointer-elim-non-leaf", "true");
590 #endif
591
592 LLVMRunFunctionPassManager(gallivm->passmgr, func);
593 func = LLVMGetNextFunction(func);
594 }
595 LLVMFinalizeFunctionPassManager(gallivm->passmgr);
596
597 if (gallivm_debug & GALLIVM_DEBUG_PERF) {
598 int64_t time_end = os_time_get();
599 int time_msec = (int)(time_end - time_begin) / 1000;
600 assert(gallivm->module_name);
601 debug_printf("optimizing module %s took %d msec\n",
602 gallivm->module_name, time_msec);
603 }
604
605 /* Dump byte code to a file */
606 if (gallivm_debug & GALLIVM_DEBUG_DUMP_BC) {
607 char filename[256];
608 assert(gallivm->module_name);
609 util_snprintf(filename, sizeof(filename), "ir_%s.bc", gallivm->module_name);
610 LLVMWriteBitcodeToFile(gallivm->module, filename);
611 debug_printf("%s written\n", filename);
612 debug_printf("Invoke as \"llc %s%s -o - %s\"\n",
613 (HAVE_LLVM >= 0x0305) ? "[-mcpu=<-mcpu option>] " : "",
614 "[-mattr=<-mattr option(s)>]",
615 filename);
616 }
617
618 if (use_mcjit) {
619 /* Setting the module's DataLayout to an empty string will cause the
620 * ExecutionEngine to copy to the DataLayout string from its target
621 * machine to the module. As of LLVM 3.8 the module and the execution
622 * engine are required to have the same DataLayout.
623 *
624 * We must make sure we do this after running the optimization passes,
625 * because those passes need a correct datalayout string. For example,
626 * if those optimization passes see an empty datalayout, they will assume
627 * this is a little endian target and will do optimizations that break big
628 * endian machines.
629 *
630 * TODO: This is just a temporary work-around. The correct solution is
631 * for gallivm_init_state() to create a TargetMachine and pull the
632 * DataLayout from there. Currently, the TargetMachine used by llvmpipe
633 * is being implicitly created by the EngineBuilder in
634 * lp_build_create_jit_compiler_for_module()
635 */
636 LLVMSetDataLayout(gallivm->module, "");
637 assert(!gallivm->engine);
638 if (!init_gallivm_engine(gallivm)) {
639 assert(0);
640 }
641 }
642 assert(gallivm->engine);
643
644 ++gallivm->compiled;
645
646 if (gallivm_debug & GALLIVM_DEBUG_ASM) {
647 LLVMValueRef llvm_func = LLVMGetFirstFunction(gallivm->module);
648
649 while (llvm_func) {
650 /*
651 * Need to filter out functions which don't have an implementation,
652 * such as the intrinsics. May not be sufficient in case of IPO?
653 * LLVMGetPointerToGlobal() will abort otherwise.
654 */
655 if (!LLVMIsDeclaration(llvm_func)) {
656 void *func_code = LLVMGetPointerToGlobal(gallivm->engine, llvm_func);
657 lp_disassemble(llvm_func, func_code);
658 }
659 llvm_func = LLVMGetNextFunction(llvm_func);
660 }
661 }
662
663 #if defined(PROFILE)
664 {
665 LLVMValueRef llvm_func = LLVMGetFirstFunction(gallivm->module);
666
667 while (llvm_func) {
668 if (!LLVMIsDeclaration(llvm_func)) {
669 void *func_code = LLVMGetPointerToGlobal(gallivm->engine, llvm_func);
670 lp_profile(llvm_func, func_code);
671 }
672 llvm_func = LLVMGetNextFunction(llvm_func);
673 }
674 }
675 #endif
676 }
677
678
679
680 func_pointer
681 gallivm_jit_function(struct gallivm_state *gallivm,
682 LLVMValueRef func)
683 {
684 void *code;
685 func_pointer jit_func;
686 int64_t time_begin = 0;
687
688 assert(gallivm->compiled);
689 assert(gallivm->engine);
690
691 if (gallivm_debug & GALLIVM_DEBUG_PERF)
692 time_begin = os_time_get();
693
694 code = LLVMGetPointerToGlobal(gallivm->engine, func);
695 assert(code);
696 jit_func = pointer_to_func(code);
697
698 if (gallivm_debug & GALLIVM_DEBUG_PERF) {
699 int64_t time_end = os_time_get();
700 int time_msec = (int)(time_end - time_begin) / 1000;
701 debug_printf(" jitting func %s took %d msec\n",
702 LLVMGetValueName(func), time_msec);
703 }
704
705 return jit_func;
706 }