Skip to content

Commit 66c88d6

Browse files
authored
Unrolled build for #142588
Rollup merge of #142588 - ZuseZ4:generic-ctx-imprv, r=oli-obk Generic ctx imprv Cleanup work for my gpu pr r? `@oli-obk`
2 parents 27eb269 + 6359123 commit 66c88d6

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
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/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BackendTypes for GenericCx<'ll, CX> {
9999
type DIVariable = &'ll llvm::debuginfo::DIVariable;
100100
}
101101

102-
impl<'ll> CodegenCx<'ll, '_> {
102+
impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
103103
pub(crate) fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
104104
let len = u64::try_from(elts.len()).expect("LLVMConstArray2 elements len overflow");
105105
unsafe { llvm::LLVMConstArray2(ty, elts.as_ptr(), len) }
106106
}
107107

108108
pub(crate) fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
109-
bytes_in_context(self.llcx, bytes)
109+
bytes_in_context(self.llcx(), bytes)
110110
}
111111

112112
pub(crate) fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {

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)