Skip to content

Commit 129c176

Browse files
committed
cleanup ir, make it valid
1 parent d8c83ca commit 129c176

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,32 +354,29 @@ fn gen_call_handling<'ll>(
354354
//%kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
355355
let a5 = builder.direct_alloca(tgt_kernel_decl, Align::EIGHT, "kernel_args");
356356

357+
// Step 1)
358+
unsafe { llvm::LLVMRustPositionBefore(builder.llbuilder, kernel_call) };
359+
builder.memset(tgt_bin_desc_alloca, cx.get_const_i8(0), cx.get_const_i64(32), Align::EIGHT);
360+
357361
// Now we allocate once per function param, a copy to be passed to one of our maps.
358362
let mut vals = vec![];
359363
let mut geps = vec![];
360364
let i32_0 = cx.get_const_i32(0);
361365
for (index, in_ty) in types.iter().enumerate() {
362366
// get function arg, store it into the alloca, and read it.
363-
let p = llvm::get_param(called, index as u32);
364-
let name = llvm::get_value_name(p);
365-
let name = str::from_utf8(&name).unwrap();
366-
let arg_name = format!("{name}.addr");
367-
let alloca = builder.direct_alloca(in_ty, Align::EIGHT, &arg_name);
367+
//let p = llvm::get_param(called, index as u32);
368+
//let name = llvm::get_value_name(p);
369+
//let name = str::from_utf8(&name).unwrap();
370+
//let arg_name = format!("{name}.addr");
371+
//let alloca = builder.direct_alloca(in_ty, Align::EIGHT, &arg_name);
368372

369373
let v = unsafe { llvm::LLVMGetOperand(kernel_call, index as u32).unwrap() };
370-
builder.store(v, alloca, Align::EIGHT);
371-
//let val = builder.load(in_ty, alloca, Align::EIGHT);
372-
//let gep = builder.inbounds_gep(cx.type_f32(), val, &[i32_0]);
373374
let gep = builder.inbounds_gep(cx.type_f32(), v, &[i32_0]);
374375
vals.push(v);
375376
//vals.push(val);
376377
geps.push(gep);
377378
}
378379

379-
// Step 1)
380-
unsafe { llvm::LLVMRustPositionBefore(builder.llbuilder, kernel_call) };
381-
builder.memset(tgt_bin_desc_alloca, cx.get_const_i8(0), cx.get_const_i64(32), Align::EIGHT);
382-
383380
let mapper_fn_ty = cx.type_func(&[cx.type_ptr()], cx.type_void());
384381
let register_lib_decl = declare_offload_fn(&cx, "__tgt_register_lib", mapper_fn_ty);
385382
let unregister_lib_decl = declare_offload_fn(&cx, "__tgt_unregister_lib", mapper_fn_ty);

0 commit comments

Comments
 (0)