Skip to content

Commit e9da5f2

Browse files
committed
Go back to the end of the stored bb instead of ip handling
1 parent 08eb6b1 commit e9da5f2

3 files changed

Lines changed: 2 additions & 39 deletions

File tree

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
430430
let fn_ty = offload_globals.mapper_fn_ty;
431431

432432
let num_args = types.len() as u64;
433-
unsafe {llvm::LLVMDumpModule(builder.llmod())};
434-
let ip = unsafe { llvm::LLVMRustGetInsertPoint(&builder.llbuilder) };
435-
let ip = ip.unwrap();
433+
let bb = builder.llbb();
436434

437435
// FIXME(Sa4dUs): dummy loads are a temp workaround, we should find a proper way to prevent these
438436
// variables from being optimized away
@@ -470,7 +468,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
470468

471469
// Step 1)
472470
unsafe {
473-
llvm::LLVMRustRestoreInsertPoint(&builder.llbuilder, ip);
471+
llvm::LLVMPositionBuilderAtEnd(&builder.llbuilder, bb);
474472
}
475473
builder.memset(tgt_bin_desc_alloca, cx.get_const_i8(0), cx.get_const_i64(32), Align::EIGHT);
476474

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,8 +2443,6 @@ unsafe extern "C" {
24432443

24442444
pub(crate) fn LLVMRustPositionBuilderPastAllocas<'a>(B: &Builder<'a>, Fn: &'a Value);
24452445
pub(crate) fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
2446-
pub(crate) fn LLVMRustGetInsertPoint<'a>(B: &Builder<'a>) -> Option<&'a Value>;
2447-
pub(crate) fn LLVMRustRestoreInsertPoint<'a>(B: &Builder<'a>, IP: &'a Value);
24482446

24492447
pub(crate) fn LLVMRustSetModulePICLevel(M: &Module);
24502448
pub(crate) fn LLVMRustSetModulePIELevel(M: &Module);

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,39 +1458,6 @@ extern "C" void LLVMRustPositionAfter(LLVMBuilderRef B, LLVMValueRef Instr) {
14581458
}
14591459
}
14601460

1461-
extern "C" LLVMValueRef LLVMRustGetInsertPoint(LLVMBuilderRef B) {
1462-
llvm::IRBuilderBase &IRB = *unwrap(B);
1463-
1464-
llvm::IRBuilderBase::InsertPoint ip = IRB.saveIP();
1465-
llvm::BasicBlock *BB = ip.getBlock();
1466-
1467-
if (!BB)
1468-
return nullptr;
1469-
1470-
auto it = ip.getPoint();
1471-
1472-
if (it == BB->end())
1473-
return nullptr;
1474-
1475-
llvm::Instruction *I = &*it;
1476-
return wrap(I);
1477-
}
1478-
1479-
extern "C" void LLVMRustRestoreInsertPoint(LLVMBuilderRef B,
1480-
LLVMValueRef Instr) {
1481-
llvm::IRBuilderBase &IRB = *unwrap(B);
1482-
1483-
if (!Instr) {
1484-
llvm::BasicBlock *BB = IRB.GetInsertBlock();
1485-
if (BB)
1486-
IRB.SetInsertPoint(BB);
1487-
return;
1488-
}
1489-
1490-
llvm::Instruction *I = unwrap<llvm::Instruction>(Instr);
1491-
IRB.SetInsertPoint(I);
1492-
}
1493-
14941461
extern "C" LLVMValueRef
14951462
LLVMRustGetFunctionCall(LLVMValueRef Fn, const char *Name, size_t NameLen) {
14961463
auto targetName = StringRef(Name, NameLen);

0 commit comments

Comments
 (0)