diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-10-02 17:19:30 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-10-02 18:06:57 +1000 |
| commit | 6a58f80a3c4cf53f8092e75c07cebd5e913cccf0 (patch) | |
| tree | 5404bf54b56a35d405429ea127fcad1861a3925f /compiler/rustc_codegen_llvm/src/context.rs | |
| parent | ffeed2b94ed432c959e3d9cf9bd5f7016f9577d3 (diff) | |
| download | rust-6a58f80a3c4cf53f8092e75c07cebd5e913cccf0.tar.gz rust-6a58f80a3c4cf53f8092e75c07cebd5e913cccf0.zip | |
Extract helper method `global_add_metadata_node`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/context.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 13 |
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 f1f3d6a8b62..d09121016d0 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -1039,6 +1039,19 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> { let md_as_val = self.get_metadata_value(md); unsafe { llvm::LLVMAddNamedMetadataOperand(module, kind_name.as_ptr(), md_as_val) }; } + + /// Helper method for the sequence of calls: + /// - `LLVMMDNodeInContext2` (to create an `llvm::MDNode` from a list of metadata) + /// - `LLVMRustGlobalAddMetadata` (to set that node as metadata of `kind_id` for `global`) + pub(crate) fn global_add_metadata_node( + &self, + global: &'ll Value, + kind_id: MetadataKindId, + md_list: &[&'ll Metadata], + ) { + let md = self.md_node_in_context(md_list); + unsafe { llvm::LLVMRustGlobalAddMetadata(global, kind_id, md) }; + } } impl HasDataLayout for CodegenCx<'_, '_> { |
