]> git.lizzy.rs Git - rust.git/commitdiff
rustc_codegen_llvm: use safe references for TargetMachine.
authorIrina Popa <irinagpopa@gmail.com>
Thu, 12 Jul 2018 15:34:59 +0000 (18:34 +0300)
committerIrina Popa <irinagpopa@gmail.com>
Mon, 30 Jul 2018 17:10:31 +0000 (20:10 +0300)
src/librustc_codegen_llvm/back/lto.rs
src/librustc_codegen_llvm/back/write.rs
src/librustc_codegen_llvm/llvm/ffi.rs

index c30a436449da4bfc428e520ed4ef95f7b3d7d54a..0a8b143ae9235d3e43e3611b8cab3d9c8226f2ef 100644 (file)
@@ -14,7 +14,7 @@
 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) {
index 9f99adc34a8c11fb63913eeabb92a7e9c2881b69..ebeb0d4bcb463821110d953913624c48a69821dc 100644 (file)
@@ -26,7 +26,7 @@
 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<F, R>(tm: TargetMachineRef,
+        unsafe fn with_codegen<F, R>(tm: &llvm::TargetMachine,
                                     llmod: &llvm::Module,
                                     no_builtins: bool,
                                     f: F) -> R
index ebbb8549b126c210716beaacb24c82dd9e28338d..566bd3c2c187038a24a3e8dd00f800b5da4e0ba4 100644 (file)
@@ -398,7 +398,6 @@ pub enum ThreadLocalMode {
 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 @@ pub fn LLVMRustDIBuilderCreateDebugLocation(Context: &'a Context,
     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 @@ pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
                                        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 @@ pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef,
                                   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 @@ pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
                                     -> 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,