about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/consts.rs
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-07-09 09:12:42 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-07-14 08:27:08 +0000
commitd3d51b4fdbd6854da015f501e6566ca17cb023e5 (patch)
tree271231c470dfbd497780f427750266ee898992dd /compiler/rustc_codegen_llvm/src/consts.rs
parentad635e5d0696076b4412dd7db7b7e8c0867d6e0c (diff)
downloadrust-d3d51b4fdbd6854da015f501e6566ca17cb023e5.tar.gz
rust-d3d51b4fdbd6854da015f501e6566ca17cb023e5.zip
Avoid a bunch of unnecessary `unsafe` blocks in cg_llvm
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/consts.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/consts.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs
index 5deddb3ed98..070a9b64486 100644
--- a/compiler/rustc_codegen_llvm/src/consts.rs
+++ b/compiler/rustc_codegen_llvm/src/consts.rs
@@ -19,11 +19,10 @@ use tracing::{debug, instrument, trace};
 
 use crate::common::{AsCCharPtr, CodegenCx};
 use crate::errors::SymbolAlreadyDefined;
-use crate::llvm::{self, True};
 use crate::type_::Type;
 use crate::type_of::LayoutLlvmExt;
 use crate::value::Value;
-use crate::{base, debuginfo};
+use crate::{base, debuginfo, llvm};
 
 pub(crate) fn const_alloc_to_llvm<'ll>(
     cx: &CodegenCx<'ll, '_>,
@@ -247,7 +246,7 @@ impl<'ll> CodegenCx<'ll, '_> {
         };
         llvm::set_initializer(gv, cv);
         set_global_alignment(self, gv, align);
-        llvm::SetUnnamedAddress(gv, llvm::UnnamedAddr::Global);
+        llvm::set_unnamed_address(gv, llvm::UnnamedAddr::Global);
         gv
     }
 
@@ -272,9 +271,8 @@ impl<'ll> CodegenCx<'ll, '_> {
             return gv;
         }
         let gv = self.static_addr_of_mut(cv, align, kind);
-        unsafe {
-            llvm::LLVMSetGlobalConstant(gv, True);
-        }
+        llvm::set_global_constant(gv, true);
+
         self.const_globals.borrow_mut().insert(cv, gv);
         gv
     }
@@ -465,7 +463,7 @@ impl<'ll> CodegenCx<'ll, '_> {
 
             // Forward the allocation's mutability (picked by the const interner) to LLVM.
             if alloc.mutability.is_not() {
-                llvm::LLVMSetGlobalConstant(g, llvm::True);
+                llvm::set_global_constant(g, true);
             }
 
             debuginfo::build_global_var_di_node(self, def_id, g);