]> git.lizzy.rs Git - rust.git/commitdiff
rustc_codegen_llvm: use safe references for PassManagerBuilder.
authorIrina Popa <irinagpopa@gmail.com>
Thu, 12 Jul 2018 13:24:09 +0000 (16:24 +0300)
committerIrina Popa <irinagpopa@gmail.com>
Mon, 30 Jul 2018 17:10:29 +0000 (20:10 +0300)
src/librustc_codegen_llvm/back/write.rs
src/librustc_codegen_llvm/llvm/ffi.rs

index ce51a3572d837bab7fe300a1b8fb00ee4ce5dda0..c54ce29b4629cb131b7b37303ba3aa1e622f858f 100644 (file)
@@ -2051,7 +2051,7 @@ pub unsafe fn with_llvm_pmb(llmod: &llvm::Module,
                             config: &ModuleConfig,
                             opt_level: llvm::CodeGenOptLevel,
                             prepare_for_thin_lto: bool,
-                            f: &mut dyn FnMut(llvm::PassManagerBuilderRef)) {
+                            f: &mut dyn FnMut(&llvm::PassManagerBuilder)) {
     use std::ptr;
 
     // Create the PassManagerBuilder for LLVM. We configure it with
index 422eb32bab8f8b8243238858e9a9f6345dd42974..8d982303614fa9af4b05b1f08c5b5a42ae3efb28 100644 (file)
@@ -393,7 +393,6 @@ pub enum ThreadLocalMode {
 extern { pub type PassManager; }
 pub type PassManagerRef = *mut PassManager;
 extern { pub type PassManagerBuilder; }
-pub type PassManagerBuilderRef = *mut PassManagerBuilder;
 extern { pub type ObjectFile; }
 extern { pub type SectionIterator; }
 pub type SectionIteratorRef = *mut SectionIterator;
@@ -1119,23 +1118,23 @@ pub fn LLVMRustBuildAtomicFence(B: &Builder,
 
     pub fn LLVMInitializePasses();
 
-    pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
-    pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
-    pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
-    pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
-    pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
+    pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
+    pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
+    pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
+    pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
+    pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: &PassManagerBuilder,
                                                          threshold: c_uint);
-    pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
+    pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: &PassManagerBuilder,
                                                            PM: PassManagerRef);
 
-    pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
+    pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: &PassManagerBuilder,
                                                              PM: PassManagerRef);
-    pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
+    pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: &PassManagerBuilder,
                                                         PM: PassManagerRef,
                                                         Internalize: Bool,
                                                         RunInliner: Bool);
     pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
-        PMB: PassManagerBuilderRef,
+        PMB: &PassManagerBuilder,
         PM: PassManagerRef) -> bool;
 
     // Stuff that's in rustllvm/ because it's not upstream yet.
@@ -1439,10 +1438,10 @@ pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
                                        -> Option<&'static mut TargetMachine>;
     pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine);
     pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: &Module);
-    pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
-                                         M: &Module,
+    pub fn LLVMRustAddBuilderLibraryInfo(PMB: &'a PassManagerBuilder,
+                                         M: &'a Module,
                                          DisableSimplifyLibCalls: bool);
-    pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
+    pub fn LLVMRustConfigurePassManagerBuilder(PMB: &PassManagerBuilder,
                                                OptLevel: CodeGenOptLevel,
                                                MergeFunctions: bool,
                                                SLPVectorize: bool,
@@ -1470,7 +1469,7 @@ pub fn LLVMRustPrintModule(PM: PassManagerRef,
     pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
     pub fn LLVMRustPrintPasses();
     pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
-    pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
+    pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
     pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
     pub fn LLVMRustMarkAllFunctionsNounwind(M: &Module);