about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/context.rs
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2025-10-02 17:33:28 +1000
committerZalathar <Zalathar@users.noreply.github.com>2025-10-02 18:06:58 +1000
commit8ef9821bf2e27bf7ab4f9a0e3d0975dc59d3d932 (patch)
tree5cdceecd6fdb6b060c32ba39ce40672472e4c703 /compiler/rustc_codegen_llvm/src/context.rs
parent6a58f80a3c4cf53f8092e75c07cebd5e913cccf0 (diff)
downloadrust-8ef9821bf2e27bf7ab4f9a0e3d0975dc59d3d932.tar.gz
rust-8ef9821bf2e27bf7ab4f9a0e3d0975dc59d3d932.zip
Extract helper method `global_set_metadata_node`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/context.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/context.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index d09121016d0..922575dd63c 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -1052,6 +1052,19 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
         let md = self.md_node_in_context(md_list);
         unsafe { llvm::LLVMRustGlobalAddMetadata(global, kind_id, md) };
     }
+
+    /// Helper method for the sequence of calls:
+    /// - `LLVMMDNodeInContext2` (to create an `llvm::MDNode` from a list of metadata)
+    /// - `LLVMGlobalSetMetadata` (to set that node as metadata of `kind_id` for `global`)
+    pub(crate) fn global_set_metadata_node(
+        &self,
+        global: &'ll Value,
+        kind_id: MetadataKindId,
+        md_list: &[&'ll Metadata],
+    ) {
+        let md = self.md_node_in_context(md_list);
+        unsafe { llvm::LLVMGlobalSetMetadata(global, kind_id, md) };
+    }
 }
 
 impl HasDataLayout for CodegenCx<'_, '_> {