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`.
This commit is contained in:
Zalathar
2025-05-10 18:26:57 +10:00
parent d1bb310a7a
commit b1094f6a0a
4 changed files with 17 additions and 11 deletions

View File

@@ -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());
}
}