diff options
| author | Rafael Ávila de Espíndola <[email protected]> | 2011-04-07 15:42:06 -0400 |
|---|---|---|
| committer | Rafael Ávila de Espíndola <[email protected]> | 2011-04-07 15:42:06 -0400 |
| commit | b4422cca2195be788d99c849e662c3c778496739 (patch) | |
| tree | 7e699c298714a46eaff380a8e501c3ad0cf3b1b4 /src | |
| parent | rustc: Reindent line. Puts out burning tinderbox. (diff) | |
| download | rust-b4422cca2195be788d99c849e662c3c778496739.tar.xz rust-b4422cca2195be788d99c849e662c3c778496739.zip | |
Add a -O option and change the Makefile to use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/driver/rustc.rs | 16 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 10 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index a1fdb387..36827b73 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -58,6 +58,7 @@ impure fn compile_input(session.session sess, eval.env env, str input, str output, bool shared, + bool optimize, vec[str] library_search_paths) { auto def = tup(0, 0); auto p = parser.new_parser(sess, env, def, input); @@ -69,7 +70,7 @@ impure fn compile_input(session.session sess, auto type_cache = typeck_result._1; // FIXME: uncomment once typestate_check works // crate = typestate_check.check_crate(crate); - trans.trans_crate(sess, crate, type_cache, output, shared); + trans.trans_crate(sess, crate, type_cache, output, shared, optimize); } impure fn pretty_print_input(session.session sess, @@ -131,6 +132,9 @@ impure fn main(vec[str] args) { let bool pretty = false; let bool glue = false; + // FIXME: Maybe we should support -O0, -O1, -Os, etc + let bool optimize = false; + auto i = 1u; auto len = _vec.len[str](args); @@ -140,6 +144,8 @@ impure fn main(vec[str] args) { if (_str.byte_len(arg) > 0u && arg.(0) == '-' as u8) { if (_str.eq(arg, "-nowarn")) { do_warn = false; + } else if (_str.eq(arg, "-O")) { + optimize = true; } else if (_str.eq(arg, "-glue")) { glue = true; } else if (_str.eq(arg, "-shared")) { @@ -189,10 +195,10 @@ impure fn main(vec[str] args) { if (glue) { alt (output_file) { case (none[str]) { - middle.trans.make_common_glue("glue.bc"); + middle.trans.make_common_glue("glue.bc", optimize); } case (some[str](?s)) { - middle.trans.make_common_glue(s); + middle.trans.make_common_glue(s, optimize); } } ret; @@ -217,11 +223,11 @@ impure fn main(vec[str] args) { parts += vec(".bc"); auto ofile = _str.concat(parts); compile_input(sess, env, ifile, ofile, shared, - library_search_paths); + optimize, library_search_paths); } case (some[str](?ofile)) { compile_input(sess, env, ifile, ofile, shared, - library_search_paths); + optimize, library_search_paths); } } } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 4f281b9c..f81c8e1d 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -7003,7 +7003,7 @@ fn make_glues(ModuleRef llmod, type_names tn) -> @glue_fns { vec_append_glue = make_vec_append_glue(llmod, tn)); } -fn make_common_glue(str output) { +fn make_common_glue(str output, bool optimize) { // FIXME: part of this is repetitive and is probably a good idea // to autogen it, but things like the memcpy implementation are not // and it might be better to just check in a .ll file. @@ -7029,14 +7029,15 @@ fn make_common_glue(str output) { trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn, llmod); - run_passes(llmod, true); + run_passes(llmod, optimize); llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(output)); llvm.LLVMDisposeModule(llmod); } fn trans_crate(session.session sess, @ast.crate crate, - &ty.type_cache type_cache, str output, bool shared) { + &ty.type_cache type_cache, str output, bool shared, + bool optimize) { auto llmod = llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"), llvm.LLVMGetGlobalContext()); @@ -7099,8 +7100,7 @@ fn trans_crate(session.session sess, @ast.crate crate, // Translate the metadata. middle.metadata.write_metadata(cx, crate); - // FIXME: Add an -O option - run_passes(llmod, true); + run_passes(llmod, optimize); llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(output)); llvm.LLVMDisposeModule(llmod); |