Skip to content

Commit

Permalink
issue #110 Enable setting opt level
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed Jul 29, 2018
1 parent 82ebd78 commit 2d646a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dmr_c/omrjit-backend/sparse-omrjit.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
9 changes: 7 additions & 2 deletions src/ravi_omrjit.c
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 2d646a0

Please sign in to comment.