Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Function>(unwrap<Value>(F))) {
Fn->addParamAttr(i, unwrap(RustAttr));
}
}

extern "C" void LLVMRustAddRetFncAttr(LLVMValueRef F,
LLVMRustAttribute RustAttr) {
if (auto *Fn = dyn_cast<Function>(unwrap<Value>(F))) {
Fn->addRetAttr(fromRust(RustAttr));
}
}

extern "C" LLVMMetadataRef LLVMRustDIGetInstMetadata(LLVMValueRef x) {
if (auto *I = dyn_cast<Instruction>(unwrap<Value>(x))) {
// auto *MD = I->getMetadata(LLVMContext::MD_dbg);
Expand Down