Skip to content

Use sess.opts.optimize instead of sess.opts.cg.opt_level for LTO optlevel #22530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustc_trans/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod);
llvm::LLVMRustAddPass(pm, "verify\0".as_ptr() as *const _);

let opt = sess.opts.cg.opt_level.unwrap_or(0) as libc::c_uint;
let opt = match sess.opts.optimize {
config::No => 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like -Clto without optimizations doesn't even perform dead code elimination, which makes LTO rather pointless, IMO.
Can we please make -Clto imply -Copt-level=2? (unless specified explicitly, of course)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While perhaps not super useful, it does allow varying axes of configuration as well as perhaps a smoke test of some form. I would be ok, however, to have -Clto switch the default optimization level as ell though.

config::Less => 1,
config::Default => 2,
config::Aggressive => 3,
};

let builder = llvm::LLVMPassManagerBuilderCreate();
llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt);
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/sepcomp-lib-lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// aux-build:sepcomp_lib.rs
// compile-flags: -C lto
// no-prefer-dynamic
// ignore-android FIXME #18800

extern crate sepcomp_lib;
use sepcomp_lib::a::one;
Expand Down