Skip to content

Commit 58402a9

Browse files
committed
rustc_codegen_llvm: don't require a builder to call add_incoming_to_phi.
1 parent 0b37b58 commit 58402a9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
552552

553553
let next = body_bx.inbounds_gep(current, &[self.const_usize(1)]);
554554
body_bx.br(header_bx.llbb());
555-
header_bx.add_incoming_to_phi(current, next, body_bx.llbb());
555+
Self::add_incoming_to_phi(current, &[next], &[body_bx.llbb()]);
556556

557557
next_bx
558558
}
@@ -1395,17 +1395,15 @@ impl Builder<'a, 'll, 'tcx> {
13951395
vals: &[&'ll Value],
13961396
bbs: &[&'ll BasicBlock],
13971397
) -> &'ll Value {
1398-
assert_eq!(vals.len(), bbs.len());
13991398
let phi = unsafe { llvm::LLVMBuildPhi(self.llbuilder, ty, UNNAMED) };
1400-
unsafe {
1401-
llvm::LLVMAddIncoming(phi, vals.as_ptr(), bbs.as_ptr(), vals.len() as c_uint);
1402-
phi
1403-
}
1399+
Self::add_incoming_to_phi(phi, vals, bbs);
1400+
phi
14041401
}
14051402

1406-
fn add_incoming_to_phi(&mut self, phi: &'ll Value, val: &'ll Value, bb: &'ll BasicBlock) {
1403+
fn add_incoming_to_phi(phi: &'ll Value, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) {
1404+
assert_eq!(vals.len(), bbs.len());
14071405
unsafe {
1408-
llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
1406+
llvm::LLVMAddIncoming(phi, vals.as_ptr(), bbs.as_ptr(), vals.len() as c_uint);
14091407
}
14101408
}
14111409

0 commit comments

Comments
 (0)