issue #110 Enable setting opt level

pull/167/head
Dibyendu Majumdar 6 years ago
parent 82ebd78a15
commit 2d646a0bde

@ -2134,7 +2134,7 @@ static bool output_fn(struct dmr_C *C, JIT_ContextRef module, struct entrypoint
function.builder =
JIT_CreateFunctionBuilder(module, function_name, freturn, nr_args, argtypes, JIT_ILBuilderImpl, &function);
void *p = JIT_Compile(function.builder);
void *p = JIT_Compile(function.builder, C->optimize);
if (p)
success = true;
@ -2188,7 +2188,7 @@ bool dmrC_omrcompile(int argc, char **argv, JIT_ContextRef module, const char *i
char *file;
struct dmr_C *C = new_dmr_C();
C->optimize = 0; /* Sparse simplifications result in incorrect IR */
C->optimize = 1; /* Default */
C->codegen = 1; /* Disables macros related to vararg processing */
C->Wdecl = 0;

@ -397,9 +397,9 @@ int raviV_compile(struct lua_State *L, struct Proto *p, ravi_compile_options_t *
membuff_init(&buf, 4096);
int (*fp)(lua_State * L) = NULL;
char *argv[] = {NULL};
char fname[30];
snprintf(fname, sizeof fname, "jit%lld", G->ravi_state->id++);
char *argv[] = { fname, "-O1", NULL };
if (!raviJ_codegen(L, p, options, fname, &buf)) {
p->ravi_jit.jit_status = RAVI_JIT_CANT_COMPILE;
@ -409,7 +409,12 @@ int raviV_compile(struct lua_State *L, struct Proto *p, ravi_compile_options_t *
ravi_writestring(L, buf.buf, strlen(buf.buf));
ravi_writeline(L);
}
if (!dmrC_omrcompile(0, argv, context, buf.buf)) {
int opt_level = G->ravi_state->opt_level_;
if (opt_level == 0)
argv[1] = "-O0";
else if (opt_level >= 2)
argv[1] = "-O2";
if (!dmrC_omrcompile(2, argv, context, buf.buf)) {
p->ravi_jit.jit_status = RAVI_JIT_CANT_COMPILE;
}
else {

Loading…
Cancel
Save