]> git.lizzy.rs Git - rust.git/commitdiff
librustc_codegen_llvm: Replace deprecated API usage
authorTomasz Miąsko <tomasz.miasko@gmail.com>
Wed, 11 Mar 2020 00:00:00 +0000 (00:00 +0000)
committerTomasz Miąsko <tomasz.miasko@gmail.com>
Wed, 11 Mar 2020 22:56:41 +0000 (23:56 +0100)
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/consts.rs
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_llvm/debuginfo/gdb.rs
src/librustc_codegen_llvm/declare.rs
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/llvm/ffi.rs
src/librustc_codegen_llvm/llvm/mod.rs

index 04c084e459eab662f2b441eafcc2ba5715b76ca4..115de2a851d6bd340b8b6e1a12fd1209a1e15142 100644 (file)
@@ -71,8 +71,7 @@ pub fn write_compressed_metadata<'tcx>(
         // flags, at least for ELF outputs, so that the
         // metadata doesn't get loaded into memory.
         let directive = format!(".section {}", section_name);
-        let directive = CString::new(directive).unwrap();
-        llvm::LLVMSetModuleInlineAsm(metadata_llmod, directive.as_ptr())
+        llvm::LLVMSetModuleInlineAsm2(metadata_llmod, directive.as_ptr().cast(), directive.len())
     }
 }
 
index 09a84aff16811a80f14db9fd288fcbdfadee73ac..619dee2909281015b2e9af96dfb6c10585031b7b 100644 (file)
@@ -1,7 +1,7 @@
 use crate::base;
 use crate::common::CodegenCx;
 use crate::debuginfo;
-use crate::llvm::{self, SetUnnamedAddr, True};
+use crate::llvm::{self, True};
 use crate::type_::Type;
 use crate::type_of::LayoutLlvmExt;
 use crate::value::Value;
@@ -183,7 +183,7 @@ impl CodegenCx<'ll, 'tcx> {
             };
             llvm::LLVMSetInitializer(gv, cv);
             set_global_alignment(&self, gv, align);
-            SetUnnamedAddr(gv, true);
+            llvm::SetUnnamedAddress(gv, llvm::UnnamedAddr::Global);
             gv
         }
     }
index 3466363ac797227b4febe21cf5099e958e5718d9..3f856c479c5a9acd715ab1f9713425a527c464ca 100644 (file)
@@ -172,7 +172,7 @@ pub unsafe fn create_module(
         llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
         llvm::LLVMRustDisposeTargetMachine(tm);
 
-        let llvm_data_layout = llvm::LLVMGetDataLayout(llmod);
+        let llvm_data_layout = llvm::LLVMGetDataLayoutStr(llmod);
         let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
             .expect("got a non-UTF8 data-layout from LLVM");
 
@@ -504,7 +504,7 @@ fn insert_intrinsic(
             self.type_variadic_func(&[], ret)
         };
         let f = self.declare_cfn(name, fn_ty);
-        llvm::SetUnnamedAddr(f, false);
+        llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No);
         self.intrinsics.borrow_mut().insert(name, f);
         f
     }
index 753a4e18faf5e7aa26b719d4d96e4e80747fa0bd..d6fbc53fd3776b2aace48dc036ae9b017e445016 100644 (file)
@@ -50,7 +50,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>) -
             llvm::LLVMSetSection(section_var, section_name.as_ptr().cast());
             llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
             llvm::LLVMSetGlobalConstant(section_var, llvm::True);
-            llvm::LLVMSetUnnamedAddr(section_var, llvm::True);
+            llvm::LLVMSetUnnamedAddress(section_var, llvm::UnnamedAddr::Global);
             llvm::LLVMRustSetLinkage(section_var, llvm::Linkage::LinkOnceODRLinkage);
             // This should make sure that the whole section is not larger than
             // the string it contains. Otherwise we get a warning from GDB.
index fab6321186b2c27363a34d60761a0724092f9861..236f5bb1bfdfb2871e0428f891b4f90f630ca3d6 100644 (file)
@@ -40,7 +40,7 @@ fn declare_raw_fn(
     llvm::SetFunctionCallConv(llfn, callconv);
     // Function addresses in Rust are never significant, allowing functions to
     // be merged.
-    llvm::SetUnnamedAddr(llfn, true);
+    llvm::SetUnnamedAddress(llfn, llvm::UnnamedAddr::Global);
 
     if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.target.options.disable_redzone) {
         llvm::Attribute::NoRedZone.apply_llfn(Function, llfn);
index 1ae9d2a6841316e4cd290f848dc68ba5e997ec72..69af175bc54decf4ea39bad0851145ca5ffbb2fc 100644 (file)
@@ -1664,7 +1664,7 @@ fn non_ptr(t: Ty<'_>) -> Ty<'_> {
                 llvm_elem_vec_ty,
             ),
         );
-        llvm::SetUnnamedAddr(f, false);
+        llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No);
         let v = bx.call(f, &[args[1].immediate(), alignment, mask, args[0].immediate()], None);
         return Ok(v);
     }
@@ -1786,7 +1786,7 @@ fn non_ptr(t: Ty<'_>) -> Ty<'_> {
             &llvm_intrinsic,
             bx.type_func(&[llvm_elem_vec_ty, llvm_pointer_vec_ty, alignment_ty, mask_ty], ret_t),
         );
-        llvm::SetUnnamedAddr(f, false);
+        llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No);
         let v = bx.call(f, &[args[0].immediate(), args[1].immediate(), alignment, mask], None);
         return Ok(v);
     }
@@ -2085,7 +2085,7 @@ macro_rules! arith {
         let vec_ty = bx.cx.type_vector(elem_ty, in_len as u64);
 
         let f = bx.declare_cfn(&llvm_intrinsic, bx.type_func(&[vec_ty, vec_ty], vec_ty));
-        llvm::SetUnnamedAddr(f, false);
+        llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No);
         let v = bx.call(f, &[lhs, rhs], None);
         return Ok(v);
     }
index 388b6c74839583535ab1e6f9474a6a02aa29a315..d4fc546b8e657822d9fc76d07e79cf901b4643e0 100644 (file)
@@ -73,6 +73,14 @@ pub enum Visibility {
     Protected = 2,
 }
 
+/// LLVMUnnamedAddr
+#[repr(C)]
+pub enum UnnamedAddr {
+    No,
+    Local,
+    Global,
+}
+
 /// LLVMDLLStorageClass
 #[derive(Copy, Clone)]
 #[repr(C)]
@@ -727,11 +735,11 @@ pub fn from_generic(kind: rustc::session::config::DebugInfo) -> Self {
     pub fn LLVMCloneModule(M: &Module) -> &Module;
 
     /// Data layout. See Module::getDataLayout.
-    pub fn LLVMGetDataLayout(M: &Module) -> *const c_char;
+    pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
     pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
 
     /// See Module::setModuleInlineAsm.
-    pub fn LLVMSetModuleInlineAsm(M: &Module, Asm: *const c_char);
+    pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
     pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
 
     /// See llvm::LLVMTypeKind::getTypeID.
@@ -1853,7 +1861,7 @@ pub fn LLVMRustDIBuilderCreateVariantPart(
         UniqueIdLen: size_t,
     ) -> &'a DIDerivedType;
 
-    pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
+    pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
 
     pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(
         Builder: &DIBuilder<'a>,
index 96014cbee5da1cdc0b288b14b756dfcfaa64a4a3..a6a3e178c6f025a973c4401e772a55d5bc134ad9 100644 (file)
@@ -106,9 +106,9 @@ pub fn UnsetComdat(val: &'a Value) {
     }
 }
 
-pub fn SetUnnamedAddr(global: &'a Value, unnamed: bool) {
+pub fn SetUnnamedAddress(global: &'a Value, unnamed: UnnamedAddr) {
     unsafe {
-        LLVMSetUnnamedAddr(global, unnamed as Bool);
+        LLVMSetUnnamedAddress(global, unnamed);
     }
 }