Skip to content

Commit 125dee7

Browse files
committed
add and use generic get_const_int function
1 parent c3ec077 commit 125dee7

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn match_args_from_caller_to_enzyme<'ll>(
114114
let mul = unsafe {
115115
llvm::LLVMBuildMul(
116116
builder.llbuilder,
117-
cx.get_const_i64(elem_bytes_size),
117+
cx.get_const_int(cx.type_i64(), elem_bytes_size),
118118
next_outer_arg,
119119
UNNAMED,
120120
)
@@ -385,7 +385,7 @@ fn generate_enzyme_call<'ll>(
385385
if attrs.width > 1 {
386386
let enzyme_width = cx.create_metadata("enzyme_width".to_string()).unwrap();
387387
args.push(cx.get_metadata_value(enzyme_width));
388-
args.push(cx.get_const_i64(attrs.width as u64));
388+
args.push(cx.get_const_int(cx.type_i64(), attrs.width as u64));
389389
}
390390

391391
let has_sret = has_sret(outer_fn);

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,8 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
679679
llvm::LLVMMetadataAsValue(self.llcx(), metadata)
680680
}
681681

682-
// FIXME(autodiff): We should split `ConstCodegenMethods` to pull the reusable parts
683-
// onto a trait that is also implemented for GenericCx.
684-
pub(crate) fn get_const_i64(&self, n: u64) -> &'ll Value {
685-
let ty = unsafe { llvm::LLVMInt64TypeInContext(self.llcx()) };
686-
unsafe { llvm::LLVMConstInt(ty, n, llvm::False) }
682+
pub(crate) fn get_const_int(&self, ty: &'ll Type, val: u64) -> &'ll Value {
683+
unsafe { llvm::LLVMConstInt(ty, val, llvm::False) }
687684
}
688685

689686
pub(crate) fn get_function(&self, name: &str) -> Option<&'ll Value> {

0 commit comments

Comments
 (0)