diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 5b94b80502109..260e66d2ce92a 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1022,6 +1022,13 @@ extern "C" { // EraseFromParent doesn't exist :( //pub fn LLVMEraseFromParent(BB: &BasicBlock) -> &Value; // Enzyme + pub fn LLVMRustAddFncParamAttr<'a>( + Instr: &'a Value, + index: c_uint, + Attr: &'a Attribute + ); + + pub fn LLVMRustAddRetAttr(V: &Value, attr: AttributeKind); pub fn LLVMRustRemoveFncAttr(V: &Value, attr: AttributeKind); pub fn LLVMRustHasDbgMetadata(I: &Value) -> bool; pub fn LLVMRustHasMetadata(I: &Value, KindID: c_uint) -> bool; diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 078c8918939b0..8f17c26f10177 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -857,6 +857,20 @@ extern "C" void LLVMRustRemoveFncAttr(LLVMValueRef F, } } +extern "C" void LLVMRustAddFncParamAttr(LLVMValueRef F, unsigned i, + LLVMAttributeRef RustAttr) { + if (auto *Fn = dyn_cast(unwrap(F))) { + Fn->addParamAttr(i, unwrap(RustAttr)); + } +} + +extern "C" void LLVMRustAddRetFncAttr(LLVMValueRef F, + LLVMRustAttribute RustAttr) { + if (auto *Fn = dyn_cast(unwrap(F))) { + Fn->addRetAttr(fromRust(RustAttr)); + } +} + extern "C" LLVMMetadataRef LLVMRustDIGetInstMetadata(LLVMValueRef x) { if (auto *I = dyn_cast(unwrap(x))) { // auto *MD = I->getMetadata(LLVMContext::MD_dbg);