about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorIrina Popa <irinagpopa@gmail.com>2018-07-12 18:34:59 +0300
committerIrina Popa <irinagpopa@gmail.com>2018-07-30 20:10:31 +0300
commit0e3a70526952c285a3187b855e2cf3398afe6b38 (patch)
tree06c9a8831557bc301fd80d9a4cb759b1b23f4d7b /src/librustc_codegen_llvm
parent55af02019433f20c53c61d490e651ca968264c7e (diff)
downloadrust-0e3a70526952c285a3187b855e2cf3398afe6b38.tar.gz
rust-0e3a70526952c285a3187b855e2cf3398afe6b38.zip
rustc_codegen_llvm: use safe references for TargetMachine.
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/back/lto.rs4
-rw-r--r--src/librustc_codegen_llvm/back/write.rs6
-rw-r--r--src/librustc_codegen_llvm/llvm/ffi.rs15
3 files changed, 12 insertions, 13 deletions
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<F, R>(tm: TargetMachineRef,
+        unsafe fn with_codegen<F, R>(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,