Implement optimize(size) and optimize(speed)

This commit is contained in:
Simonas Kazlauskas 2018-10-27 15:29:06 +03:00
parent 095b44c83b
commit f38d0da893
26 changed files with 260 additions and 108 deletions

View file

@ -144,16 +144,17 @@ pub fn is_pie_binary(sess: &Session) -> bool {
}
pub unsafe fn create_module(
sess: &Session,
tcx: TyCtxt,
llcx: &'ll llvm::Context,
mod_name: &str,
) -> &'ll llvm::Module {
let sess = tcx.sess;
let mod_name = SmallCStr::new(mod_name);
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
// Ensure the data-layout values hardcoded remain the defaults.
if sess.target.target.options.is_builtin {
let tm = ::back::write::create_target_machine(sess, false);
let tm = ::back::write::create_target_machine(tcx, false);
llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
llvm::LLVMRustDisposeTargetMachine(tm);