Skip to content

Commit 0e3a705

Browse files
committed
rustc_codegen_llvm: use safe references for TargetMachine.
1 parent 55af020 commit 0e3a705

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/librustc_codegen_llvm/back/lto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use back::write::{ModuleConfig, with_llvm_pmb, CodegenContext};
1414
use back::write;
1515
use errors::{FatalError, Handler};
1616
use llvm::archive_ro::ArchiveRO;
17-
use llvm::{TargetMachineRef, True, False};
17+
use llvm::{True, False};
1818
use llvm;
1919
use rustc::hir::def_id::LOCAL_CRATE;
2020
use rustc::middle::exported_symbols::SymbolExportLevel;
@@ -452,7 +452,7 @@ fn thin_lto(diag_handler: &Handler,
452452
}
453453

454454
fn run_pass_manager(cgcx: &CodegenContext,
455-
tm: TargetMachineRef,
455+
tm: &llvm::TargetMachine,
456456
llmod: &llvm::Module,
457457
config: &ModuleConfig,
458458
thin: bool) {

src/librustc_codegen_llvm/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc::session::Session;
2626
use rustc::util::nodemap::FxHashMap;
2727
use time_graph::{self, TimeGraph, Timeline};
2828
use llvm;
29-
use llvm::{TargetMachineRef, PassManagerRef, DiagnosticInfoRef};
29+
use llvm::{PassManagerRef, DiagnosticInfoRef};
3030
use llvm::SMDiagnosticRef;
3131
use {CodegenResults, ModuleSource, ModuleCodegen, CompiledModule, ModuleKind};
3232
use CrateInfo;
@@ -94,7 +94,7 @@ pub fn llvm_err(handler: &errors::Handler, msg: String) -> FatalError {
9494

9595
pub fn write_output_file(
9696
handler: &errors::Handler,
97-
target: llvm::TargetMachineRef,
97+
target: &llvm::TargetMachine,
9898
pm: llvm::PassManagerRef,
9999
m: &llvm::Module,
100100
output: &Path,
@@ -638,7 +638,7 @@ unsafe fn codegen(cgcx: &CodegenContext,
638638
// pass manager passed to the closure should be ensured to not
639639
// escape the closure itself, and the manager should only be
640640
// used once.
641-
unsafe fn with_codegen<F, R>(tm: TargetMachineRef,
641+
unsafe fn with_codegen<F, R>(tm: &llvm::TargetMachine,
642642
llmod: &llvm::Module,
643643
no_builtins: bool,
644644
f: F) -> R

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ extern { pub type SectionIterator; }
398398
pub type SectionIteratorRef = *mut SectionIterator;
399399
extern { pub type Pass; }
400400
extern { pub type TargetMachine; }
401-
pub type TargetMachineRef = *const TargetMachine;
402401
extern { pub type Archive; }
403402
pub type ArchiveRef = *mut Archive;
404403
extern { pub type ArchiveIterator; }
@@ -1417,10 +1416,10 @@ extern "C" {
14171416
pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
14181417
pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: &'static mut Pass);
14191418

1420-
pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool;
1419+
pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
14211420

1422-
pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1423-
pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1421+
pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
1422+
pub fn LLVMRustPrintTargetFeatures(T: &TargetMachine);
14241423

14251424
pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
14261425
CPU: *const c_char,
@@ -1436,7 +1435,7 @@ extern "C" {
14361435
Singlethread: bool)
14371436
-> Option<&'static mut TargetMachine>;
14381437
pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
1439-
pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: &Module);
1438+
pub fn LLVMRustAddAnalysisPasses(T: &TargetMachine, PM: PassManagerRef, M: &Module);
14401439
pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
14411440
M: &'a Module,
14421441
DisableSimplifyLibCalls: bool);
@@ -1452,9 +1451,9 @@ extern "C" {
14521451
M: &Module,
14531452
DisableSimplifyLibCalls: bool);
14541453
pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: &Module);
1455-
pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1454+
pub fn LLVMRustWriteOutputFile(T: &'a TargetMachine,
14561455
PM: PassManagerRef,
1457-
M: &Module,
1456+
M: &'a Module,
14581457
Output: *const c_char,
14591458
FileType: FileType)
14601459
-> LLVMRustResult;
@@ -1522,7 +1521,7 @@ extern "C" {
15221521
-> RustArchiveMemberRef;
15231522
pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
15241523

1525-
pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &Module, TM: TargetMachineRef);
1524+
pub fn LLVMRustSetDataLayoutFromTargetMachine(M: &'a Module, TM: &'a TargetMachine);
15261525

15271526
pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
15281527
Inputs: *const &Value,

0 commit comments

Comments
 (0)