From 0e3a70526952c285a3187b855e2cf3398afe6b38 Mon Sep 17 00:00:00 2001 From: Irina Popa Date: Thu, 12 Jul 2018 18:34:59 +0300 Subject: rustc_codegen_llvm: use safe references for TargetMachine. --- src/librustc_codegen_llvm/back/lto.rs | 4 ++-- src/librustc_codegen_llvm/back/write.rs | 6 +++--- src/librustc_codegen_llvm/llvm/ffi.rs | 15 +++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/librustc_codegen_llvm') diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index c30a436449d..0a8b143ae92 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -14,7 +14,7 @@ use back::write::{ModuleConfig, with_llvm_pmb, CodegenContext}; use back::write; use errors::{FatalError, Handler}; use llvm::archive_ro::ArchiveRO; -use llvm::{TargetMachineRef, True, False}; +use llvm::{True, False}; use llvm; use rustc::hir::def_id::LOCAL_CRATE; use rustc::middle::exported_symbols::SymbolExportLevel; @@ -452,7 +452,7 @@ fn thin_lto(diag_handler: &Handler, } fn run_pass_manager(cgcx: &CodegenContext, - tm: TargetMachineRef, + tm: &llvm::TargetMachine, llmod: &llvm::Module, config: &ModuleConfig, thin: bool) { diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 9f99adc34a8..ebeb0d4bcb4 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -26,7 +26,7 @@ use rustc::session::Session; use rustc::util::nodemap::FxHashMap; use time_graph::{self, TimeGraph, Timeline}; use llvm; -use llvm::{TargetMachineRef, PassManagerRef, DiagnosticInfoRef}; +use llvm::{PassManagerRef, DiagnosticInfoRef}; use llvm::SMDiagnosticRef; use {CodegenResults, ModuleSource, ModuleCodegen, CompiledModule, ModuleKind}; use CrateInfo; @@ -94,7 +94,7 @@ pub fn llvm_err(handler: &errors::Handler, msg: String) -> FatalError { pub fn write_output_file( handler: &errors::Handler, - target: llvm::TargetMachineRef, + target: &llvm::TargetMachine, pm: llvm::PassManagerRef, m: &llvm::Module, output: &Path, @@ -638,7 +638,7 @@ unsafe fn codegen(cgcx: &CodegenContext, // pass manager passed to the closure should be ensured to not // escape the closure itself, and the manager should only be // used once. - unsafe fn with_codegen(tm: TargetMachineRef, + unsafe fn with_codegen(tm: &llvm::TargetMachine, llmod: &llvm::Module, no_builtins: bool, f: F) -> R diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index ebbb8549b12..566bd3c2c18 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -398,7 +398,6 @@ extern { pub type SectionIterator; } pub type SectionIteratorRef = *mut SectionIterator; extern { pub type Pass; } extern { pub type TargetMachine; } -pub type TargetMachineRef = *const TargetMachine; extern { pub type Archive; } pub type ArchiveRef = *mut Archive; extern { pub type ArchiveIterator; } @@ -1417,10 +1416,10 @@ extern "C" { pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>; pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: &'static mut Pass); - pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool; + pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool; - pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef); - pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef); + pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine); + pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine); pub fn LLVMRustCreateTargetMachine(Triple: *const c_char, CPU: *const c_char, @@ -1436,7 +1435,7 @@ extern "C" { Singlethread: bool) -> Option<&'static mut TargetMachine>; pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); - pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: &Module); + pub fn LLVMRustAddAnalysisPasses(T: &TargetMachine, PM: PassManagerRef, M: &Module); pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder, M: &'a Module, DisableSimplifyLibCalls: bool); @@ -1452,9 +1451,9 @@ extern "C" { M: &Module, DisableSimplifyLibCalls: bool); pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: &Module); - pub fn LLVMRustWriteOutputFile(T: TargetMachineRef, + pub fn LLVMRustWriteOutputFile(T: &'a TargetMachine, PM: PassManagerRef, - M: &Module, + M: &'a Module, Output: *const c_char, FileType: FileType) -> LLVMRustResult; @@ -1522,7 +1521,7 @@ extern "C" { -> RustArchiveMemberRef; pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef); - pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &Module, TM: TargetMachineRef); + pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine); pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char, Inputs: *const &Value, -- cgit 1.4.1-3-g733a5