Skip to content

Commit b5da389

Browse files
committed
auto merge of #6799 : Aatch/rust/pass-refactor, r=graydon
This refactors pass handling to use the argument names, so it can be used in a similar manner to `opt`. This may be slightly less efficient than the previous version, but it is much easier to maintain. It also adds in the ability to specify a custom pipeline on the command line, this overrides the normal passes, however. This should completely close #2396.
2 parents bd30285 + faf1afe commit b5da389

File tree

8 files changed

+321
-496
lines changed

8 files changed

+321
-496
lines changed

src/librustc/back/link.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ pub mod write {
202202
output_type: output_type,
203203
output: &Path) {
204204
unsafe {
205+
llvm::LLVMInitializePasses();
206+
205207
let opts = sess.opts;
206208
if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); }
207209
let td = mk_target_data(sess.targ_cfg.target_strs.data_layout);
@@ -232,14 +234,21 @@ pub mod write {
232234
let mut mpm = passes::PassManager::new(td.lltd);
233235

234236
if !sess.no_verify() {
235-
mpm.addPass(llvm::LLVMCreateVerifierPass());
237+
mpm.add_pass_from_name("verify");
236238
}
237239

238-
if sess.lint_llvm() {
239-
mpm.addPass(llvm::LLVMCreateLintPass());
240-
}
240+
let passes = if sess.opts.custom_passes.len() > 0 {
241+
copy sess.opts.custom_passes
242+
} else {
243+
if sess.lint_llvm() {
244+
mpm.add_pass_from_name("lint");
245+
}
246+
passes::create_standard_passes(opts.optimize)
247+
};
248+
241249

242-
passes::populatePassManager(&mut mpm, opts.optimize);
250+
debug!("Passes: %?", passes);
251+
passes::populate_pass_manager(sess, &mut mpm, passes);
243252

244253
debug!("Running Module Optimization Pass");
245254
mpm.run(llmod);

0 commit comments

Comments
 (0)