Skip to content

Commit eba256f

Browse files
authored
Adding Function Parameter + Return Attributes (#132)
* adding Fnc param + return attributes
1 parent 2ea73a7 commit eba256f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,13 @@ extern "C" {
10221022
// EraseFromParent doesn't exist :(
10231023
//pub fn LLVMEraseFromParent(BB: &BasicBlock) -> &Value;
10241024
// Enzyme
1025+
pub fn LLVMRustAddFncParamAttr<'a>(
1026+
Instr: &'a Value,
1027+
index: c_uint,
1028+
Attr: &'a Attribute
1029+
);
1030+
1031+
pub fn LLVMRustAddRetAttr(V: &Value, attr: AttributeKind);
10251032
pub fn LLVMRustRemoveFncAttr(V: &Value, attr: AttributeKind);
10261033
pub fn LLVMRustHasDbgMetadata(I: &Value) -> bool;
10271034
pub fn LLVMRustHasMetadata(I: &Value, KindID: c_uint) -> bool;

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,20 @@ extern "C" void LLVMRustRemoveFncAttr(LLVMValueRef F,
857857
}
858858
}
859859

860+
extern "C" void LLVMRustAddFncParamAttr(LLVMValueRef F, unsigned i,
861+
LLVMAttributeRef RustAttr) {
862+
if (auto *Fn = dyn_cast<Function>(unwrap<Value>(F))) {
863+
Fn->addParamAttr(i, unwrap(RustAttr));
864+
}
865+
}
866+
867+
extern "C" void LLVMRustAddRetFncAttr(LLVMValueRef F,
868+
LLVMRustAttribute RustAttr) {
869+
if (auto *Fn = dyn_cast<Function>(unwrap<Value>(F))) {
870+
Fn->addRetAttr(fromRust(RustAttr));
871+
}
872+
}
873+
860874
extern "C" LLVMMetadataRef LLVMRustDIGetInstMetadata(LLVMValueRef x) {
861875
if (auto *I = dyn_cast<Instruction>(unwrap<Value>(x))) {
862876
// auto *MD = I->getMetadata(LLVMContext::MD_dbg);

0 commit comments

Comments
 (0)