Skip to content

Commit e954660

Browse files
committed
rustc_codegen_llvm: use safe references for PassManagerBuilder.
1 parent 2f73cef commit e954660

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/librustc_codegen_llvm/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ pub unsafe fn with_llvm_pmb(llmod: &llvm::Module,
20512051
config: &ModuleConfig,
20522052
opt_level: llvm::CodeGenOptLevel,
20532053
prepare_for_thin_lto: bool,
2054-
f: &mut dyn FnMut(llvm::PassManagerBuilderRef)) {
2054+
f: &mut dyn FnMut(&llvm::PassManagerBuilder)) {
20552055
use std::ptr;
20562056

20572057
// Create the PassManagerBuilder for LLVM. We configure it with

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ extern { pub type MemoryBuffer; }
393393
extern { pub type PassManager; }
394394
pub type PassManagerRef = *mut PassManager;
395395
extern { pub type PassManagerBuilder; }
396-
pub type PassManagerBuilderRef = *mut PassManagerBuilder;
397396
extern { pub type ObjectFile; }
398397
extern { pub type SectionIterator; }
399398
pub type SectionIteratorRef = *mut SectionIterator;
@@ -1119,23 +1118,23 @@ extern "C" {
11191118

11201119
pub fn LLVMInitializePasses();
11211120

1122-
pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1123-
pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1124-
pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
1125-
pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
1126-
pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
1121+
pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
1122+
pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
1123+
pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
1124+
pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
1125+
pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: &PassManagerBuilder,
11271126
threshold: c_uint);
1128-
pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
1127+
pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: &PassManagerBuilder,
11291128
PM: PassManagerRef);
11301129

1131-
pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
1130+
pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: &PassManagerBuilder,
11321131
PM: PassManagerRef);
1133-
pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
1132+
pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: &PassManagerBuilder,
11341133
PM: PassManagerRef,
11351134
Internalize: Bool,
11361135
RunInliner: Bool);
11371136
pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
1138-
PMB: PassManagerBuilderRef,
1137+
PMB: &PassManagerBuilder,
11391138
PM: PassManagerRef) -> bool;
11401139

11411140
// Stuff that's in rustllvm/ because it's not upstream yet.
@@ -1439,10 +1438,10 @@ extern "C" {
14391438
-> Option<&'static mut TargetMachine>;
14401439
pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
14411440
pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: &Module);
1442-
pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1443-
M: &Module,
1441+
pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
1442+
M: &'a Module,
14441443
DisableSimplifyLibCalls: bool);
1445-
pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1444+
pub fn LLVMRustConfigurePassManagerBuilder(PMB: &PassManagerBuilder,
14461445
OptLevel: CodeGenOptLevel,
14471446
MergeFunctions: bool,
14481447
SLPVectorize: bool,
@@ -1470,7 +1469,7 @@ extern "C" {
14701469
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
14711470
pub fn LLVMRustPrintPasses();
14721471
pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
1473-
pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
1472+
pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
14741473
pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
14751474
pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);
14761475

0 commit comments

Comments
 (0)