Skip to content

Commit

Permalink
Add -O option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arch D. Robison committed Nov 21, 2014
1 parent d7614b7 commit 8aca539
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4624,6 +4624,8 @@ static void init_julia_llvm_env(Module *m)
jl_TargetMachine->addAnalysisPasses(*FPM);
#endif
FPM->add(createTypeBasedAliasAnalysisPass());
if (jl_compileropts.opt_level>=1)
FPM->add(createBasicAliasAnalysisPass());
// list of passes from vmkit
FPM->add(createCFGSimplificationPass()); // Clean up disgusting code
FPM->add(createPromoteMemoryToRegisterPass());// Kill useless allocas
Expand Down Expand Up @@ -4671,8 +4673,12 @@ static void init_julia_llvm_env(Module *m)
#endif
//FPM->add(createLoopStrengthReducePass()); // (jwb added)

#if LLVM35 && !defined(INSTCOMBINE_BUG)
if (jl_compileropts.opt_level>=1)
FPM->add(createSLPVectorizerPass()); // Vectorize straight-line code
#endif

#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 3 && !defined(INSTCOMBINE_BUG)
FPM->add(createSLPVectorizerPass()); // Vectorize straight-line code
FPM->add(createLoopVectorizePass()); // Vectorize loops
#endif
#ifndef INSTCOMBINE_BUG
Expand All @@ -4691,6 +4697,10 @@ static void init_julia_llvm_env(Module *m)
#endif
FPM->add(createJumpThreadingPass()); // Thread jumps
FPM->add(createDeadStoreEliminationPass()); // Delete dead stores
#if LLVM33 && !LLVM35 && !defined(INSTCOMBINE_BUG)
if (jl_compileropts.opt_level>=1)
FPM->add(createSLPVectorizerPass()); // Vectorize straight-line code
#endif

FPM->add(createAggressiveDCEPass()); // Delete dead instructions
//FPM->add(createCFGSimplificationPass()); // Merge & remove BBs
Expand Down
3 changes: 2 additions & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ jl_compileropts_t jl_compileropts = { NULL, // build_path
JL_COMPILEROPT_CHECK_BOUNDS_DEFAULT,
JL_COMPILEROPT_DUMPBITCODE_OFF,
0, // int_literals
JL_COMPILEROPT_COMPILE_DEFAULT
JL_COMPILEROPT_COMPILE_DEFAULT,
0 // opt_level
};

int jl_boot_file_loaded = 0;
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@ typedef struct {
int8_t dumpbitcode;
int int_literals;
int8_t compile_enabled;
int8_t opt_level;
} jl_compileropts_t;

extern DLLEXPORT jl_compileropts_t jl_compileropts;
Expand Down
7 changes: 6 additions & 1 deletion ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ static const char *opts =
" --track-allocation={none|user|all}\n"
" Count bytes allocated by each source line\n"
" --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)\n"
" -O, --optimize Run time-intensive code optimizations\n"
" --int-literals={32|64} Select integer literal size independent of platform\n"
" --dump-bitcode={yes|no} Dump bitcode for the system image (used with --build)\n";

void parse_opts(int *argcp, char ***argvp)
{
static char* shortopts = "+H:T:hJ:";
static char* shortopts = "+H:T:hJ:O";
static struct option longopts[] = {
{ "home", required_argument, 0, 'H' },
{ "tab", required_argument, 0, 'T' },
Expand All @@ -101,6 +102,7 @@ void parse_opts(int *argcp, char ***argvp)
{ "code-coverage", optional_argument, 0, 'c' },
{ "track-allocation",required_argument, 0, 'm' },
{ "check-bounds", required_argument, 0, 300 },
{ "optimize", no_argument, 0, 'O' },
{ "int-literals", required_argument, 0, 301 },
{ "dump-bitcode", required_argument, 0, 302 },
{ "compile", required_argument, 0, 303 },
Expand Down Expand Up @@ -135,6 +137,9 @@ void parse_opts(int *argcp, char ***argvp)
case 'h':
printf("%s%s", usage, opts);
exit(0);
case 'O':
jl_compileropts.opt_level = 1;
break;
case 'c':
if (optarg != NULL) {
if (!strcmp(optarg,"user"))
Expand Down

0 comments on commit 8aca539

Please sign in to comment.