Skip to content

Commit a3baddb

Browse files
committed
cleaning up code
1 parent 2b176de commit a3baddb

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ impl<'a, 'll, CX: Borrow<SCx<'ll>>> GenericBuilder<'a, 'll, CX> {
119119
bx
120120
}
121121

122-
pub(crate) fn my_alloca2(&mut self, ty: &'ll Type, align: Align, name: &str) -> &'ll Value {
122+
// The generic builder has less functionality and thus (unlike the other alloca) we can not
123+
// easily jump to the beginning of the function to place our allocas there. We trust the user
124+
// to manually do that. FIXME(offload): improve the genericCx and add more llvm wrappers to
125+
// handle this.
126+
pub(crate) fn direct_alloca(&mut self, ty: &'ll Type, align: Align, name: &str) -> &'ll Value {
123127
let val = unsafe {
124128
let alloca = llvm::LLVMBuildAlloca(self.llbuilder, ty, UNNAMED);
125129
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,16 @@ fn gen_call_handling<'ll>(
307307
// %6 = alloca %struct.__tgt_bin_desc, align 8
308308
unsafe { llvm::LLVMRustPositionBuilderPastAllocas(builder.llbuilder, main_fn) };
309309

310-
let tgt_bin_desc_alloca = builder.my_alloca2(tgt_bin_desc, Align::EIGHT, "EmptyDesc");
310+
let tgt_bin_desc_alloca = builder.direct_alloca(tgt_bin_desc, Align::EIGHT, "EmptyDesc");
311311

312312
let ty = cx.type_array(cx.type_ptr(), num_args);
313313
// Baseptr are just the input pointer to the kernel, stored in a local alloca
314-
let a1 = builder.my_alloca2(ty, Align::EIGHT, ".offload_baseptrs");
314+
let a1 = builder.direct_alloca(ty, Align::EIGHT, ".offload_baseptrs");
315315
// Ptrs are the result of a gep into the baseptr, at least for our trivial types.
316-
let a2 = builder.my_alloca2(ty, Align::EIGHT, ".offload_ptrs");
316+
let a2 = builder.direct_alloca(ty, Align::EIGHT, ".offload_ptrs");
317317
// These represent the sizes in bytes, e.g. the entry for `&[f64; 16]` will be 8*16.
318318
let ty2 = cx.type_array(cx.type_i64(), num_args);
319-
let a4 = builder.my_alloca2(ty2, Align::EIGHT, ".offload_sizes");
319+
let a4 = builder.direct_alloca(ty2, Align::EIGHT, ".offload_sizes");
320320
// Now we allocate once per function param, a copy to be passed to one of our maps.
321321
let mut vals = vec![];
322322
let mut geps = vec![];

0 commit comments

Comments
 (0)