Skip to content

Commit 1080ac5

Browse files
committed
rustc: Add a -noverify option
1 parent d1b9ddc commit 1080ac5

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/comp/driver/rustc.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ fn compile_input(session.session sess,
6161
str input, str output,
6262
bool shared,
6363
bool optimize,
64+
bool verify,
6465
trans.output_type ot,
6566
vec[str] library_search_paths) {
6667
auto def = tup(0, 0);
@@ -76,7 +77,7 @@ fn compile_input(session.session sess,
7677
// FIXME: uncomment once typestate_check works
7778
// crate = typestate_check.check_crate(crate);
7879
trans.trans_crate(sess, crate, type_cache, output, shared, optimize,
79-
ot);
80+
verify, ot);
8081
}
8182

8283
fn pretty_print_input(session.session sess,
@@ -106,6 +107,7 @@ options:
106107
-pp pretty-print the input instead of compiling
107108
-ls list the symbols defined by a crate file
108109
-L <path> add a directory to the library search path
110+
-noverify suppress LLVM verification step (slight speedup)
109111
-h display this message\n\n");
110112
}
111113

@@ -140,6 +142,7 @@ fn main(vec[str] args) {
140142
let bool ls = false;
141143
auto ot = trans.output_type_bitcode;
142144
let bool glue = false;
145+
let bool verify = true;
143146

144147
// FIXME: Maybe we should support -O0, -O1, -Os, etc
145148
let bool optimize = false;
@@ -185,6 +188,8 @@ fn main(vec[str] args) {
185188
usage(sess, args.(0));
186189
sess.err("-L requires an argument");
187190
}
191+
} else if (_str.eq(arg, "-noverify")) {
192+
verify = false;
188193
} else if (_str.eq(arg, "-h")) {
189194
usage(sess, args.(0));
190195
} else {
@@ -212,10 +217,11 @@ fn main(vec[str] args) {
212217
if (glue) {
213218
alt (output_file) {
214219
case (none[str]) {
215-
middle.trans.make_common_glue("glue.bc", optimize, ot);
220+
middle.trans.make_common_glue("glue.bc", optimize, verify,
221+
ot);
216222
}
217223
case (some[str](?s)) {
218-
middle.trans.make_common_glue(s, optimize, ot);
224+
middle.trans.make_common_glue(s, optimize, verify, ot);
219225
}
220226
}
221227
ret;
@@ -241,12 +247,12 @@ fn main(vec[str] args) {
241247
parts += vec(".bc");
242248
auto ofile = _str.concat(parts);
243249
compile_input(sess, env, ifile, ofile, shared,
244-
optimize, ot,
250+
optimize, verify, ot,
245251
library_search_paths);
246252
}
247253
case (some[str](?ofile)) {
248254
compile_input(sess, env, ifile, ofile, shared,
249-
optimize, ot,
255+
optimize, verify, ot,
250256
library_search_paths);
251257
}
252258
}

src/comp/middle/trans.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6965,7 +6965,7 @@ fn is_object_or_assembly(output_type ot) -> bool {
69656965
ret false;
69666966
}
69676967

6968-
fn run_passes(ModuleRef llmod, bool opt, str output,
6968+
fn run_passes(ModuleRef llmod, bool opt, bool verify, str output,
69696969
output_type ot) {
69706970
auto pm = mk_pass_manager();
69716971

@@ -7030,7 +7030,10 @@ fn run_passes(ModuleRef llmod, bool opt, str output,
70307030
llvm.LLVMAddDeadTypeEliminationPass(pm.llpm);
70317031
llvm.LLVMAddConstantMergePass(pm.llpm);
70327032
}
7033-
llvm.LLVMAddVerifierPass(pm.llpm);
7033+
7034+
if (verify) {
7035+
llvm.LLVMAddVerifierPass(pm.llpm);
7036+
}
70347037

70357038
if (is_object_or_assembly(ot)) {
70367039
let int LLVMAssemblyFile = 0;
@@ -7385,7 +7388,7 @@ fn make_glues(ModuleRef llmod, type_names tn) -> @glue_fns {
73857388
vec_append_glue = make_vec_append_glue(llmod, tn));
73867389
}
73877390

7388-
fn make_common_glue(str output, bool optimize,
7391+
fn make_common_glue(str output, bool optimize, bool verify,
73897392
output_type ot) {
73907393
// FIXME: part of this is repetitive and is probably a good idea
73917394
// to autogen it, but things like the memcpy implementation are not
@@ -7412,7 +7415,7 @@ fn make_common_glue(str output, bool optimize,
74127415

74137416
trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn, llmod);
74147417

7415-
run_passes(llmod, optimize, output, ot);
7418+
run_passes(llmod, optimize, verify, output, ot);
74167419
}
74177420

74187421
fn create_module_map(@crate_ctxt ccx) -> ValueRef {
@@ -7465,7 +7468,7 @@ fn create_crate_map(@crate_ctxt ccx) -> ValueRef {
74657468

74667469
fn trans_crate(session.session sess, @ast.crate crate,
74677470
&ty.type_cache type_cache, str output, bool shared,
7468-
bool optimize, output_type ot) {
7471+
bool optimize, bool verify, output_type ot) {
74697472
auto llmod =
74707473
llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"),
74717474
llvm.LLVMGetGlobalContext());
@@ -7535,7 +7538,7 @@ fn trans_crate(session.session sess, @ast.crate crate,
75357538
// Translate the metadata.
75367539
middle.metadata.write_metadata(cx.ccx, crate);
75377540

7538-
run_passes(llmod, optimize, output, ot);
7541+
run_passes(llmod, optimize, verify, output, ot);
75397542
}
75407543

75417544
//

0 commit comments

Comments
 (0)