Skip to content

Commit ab54904

Browse files
committed
add inline attr to remove one indirection
1 parent 86dedf7 commit ab54904

File tree

1 file changed

+6
-0
lines changed
  • compiler/rustc_codegen_llvm/src/back

1 file changed

+6
-0
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,12 @@ pub(crate) unsafe fn enzyme_ad(
10691069
_ => unreachable!(),
10701070
};
10711071
let mut res: &Value = tmp.0;
1072+
// res is getting wrapped, but we don't want the perf overhead of a fnc call indirection.
1073+
// So we'll add an alwaysinline attribute to let llvm handle it for us.
1074+
let always_inline = llvm::AttributeKind::AlwaysInline;
1075+
let attr = llvm::LLVMRustCreateAttrNoValue(llcx, always_inline);
1076+
llvm::LLVMRustAddFunctionAttributes(res, 9, &attr, 1);
1077+
10721078
let size_positions: Vec<usize> = tmp.1;
10731079

10741080
let f_return_type = LLVMGetReturnType(LLVMGlobalGetValueType(res));

0 commit comments

Comments
 (0)