From b1094f6a0a489bb1bc2be6ca17d2bec269bd9364 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 10 May 2025 18:26:57 +1000 Subject: Add a safe wrapper for `LLVMAppendModuleInlineAsm` This patch also changes the Rust-side declaration to take `*const c_uchar` instead of `*const c_char`, to avoid the need for `AsCCharPtr`. --- compiler/rustc_codegen_llvm/src/llvm/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/rustc_codegen_llvm/src/llvm/mod.rs') diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index d14aab06073..7dbcfb508ce 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -440,3 +440,11 @@ pub(crate) fn set_dso_local<'ll>(v: &'ll Value) { LLVMRustSetDSOLocal(v, true); } } + +/// Safe wrapper for `LLVMAppendModuleInlineAsm`, which delegates to +/// `Module::appendModuleInlineAsm`. +pub(crate) fn append_module_inline_asm<'ll>(llmod: &'ll Module, asm: &[u8]) { + unsafe { + LLVMAppendModuleInlineAsm(llmod, asm.as_ptr(), asm.len()); + } +} -- cgit 1.4.1-3-g733a5