Skip to content

Commit ff6b398

Browse files
committed
Use bx.switch_to_block where possible
1 parent ddbbded commit ff6b398

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/builder.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
116116

117117
// NOTE: since jumps were added and compare_exchange doesn't expect this, the current blocks in the
118118
// state need to be updated.
119-
self.block = Some(while_block);
120-
*self.cx.current_block.borrow_mut() = Some(while_block);
119+
self.switch_to_block(while_block);
121120

122121
let comparison_operator =
123122
match operation {
@@ -134,8 +133,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
134133

135134
// NOTE: since jumps were added in a place rustc does not expect, the current blocks in the
136135
// state need to be updated.
137-
self.block = Some(after_block);
138-
*self.cx.current_block.borrow_mut() = Some(after_block);
136+
self.switch_to_block(after_block);
139137

140138
return_value.to_rvalue()
141139
}
@@ -1021,8 +1019,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
10211019

10221020
// NOTE: since jumps were added in a place rustc does not expect, the current blocks in the
10231021
// state need to be updated.
1024-
self.block = Some(after_block);
1025-
*self.cx.current_block.borrow_mut() = Some(after_block);
1022+
self.switch_to_block(after_block);
10261023

10271024
variable.to_rvalue()
10281025
}

src/int.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
148148

149149
// NOTE: since jumps were added in a place rustc does not expect, the current block in the
150150
// state need to be updated.
151-
self.block = Some(after_block);
152-
*self.cx.current_block.borrow_mut() = Some(after_block);
151+
self.switch_to_block(after_block);
153152

154153
result.to_rvalue()
155154
}
@@ -494,8 +493,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
494493

495494
// NOTE: since jumps were added in a place rustc does not expect, the current block in the
496495
// state need to be updated.
497-
self.block = Some(after_block);
498-
*self.cx.current_block.borrow_mut() = Some(after_block);
496+
self.switch_to_block(after_block);
499497

500498
result.to_rvalue()
501499
}

src/intrinsic/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
186186
// NOTE: since jumps were added in a place
187187
// count_leading_zeroes() does not expect, the current blocks
188188
// in the state need to be updated.
189-
*self.current_block.borrow_mut() = Some(else_block);
190-
self.block = Some(else_block);
189+
self.switch_to_block(else_block);
191190

192191
let zeros =
193192
match name {
@@ -200,8 +199,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
200199

201200
// NOTE: since jumps were added in a place rustc does not
202201
// expect, the current blocks in the state need to be updated.
203-
*self.current_block.borrow_mut() = Some(after_block);
204-
self.block = Some(after_block);
202+
self.switch_to_block(after_block);
205203

206204
result.to_rvalue()
207205
}
@@ -1003,8 +1001,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
10031001

10041002
// NOTE: since jumps were added in a place rustc does not
10051003
// expect, the current blocks in the state need to be updated.
1006-
*self.current_block.borrow_mut() = Some(after_block);
1007-
self.block = Some(after_block);
1004+
self.switch_to_block(after_block);
10081005

10091006
res.to_rvalue()
10101007
}
@@ -1074,8 +1071,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
10741071

10751072
// NOTE: since jumps were added in a place rustc does not
10761073
// expect, the current blocks in the state need to be updated.
1077-
*self.current_block.borrow_mut() = Some(after_block);
1078-
self.block = Some(after_block);
1074+
self.switch_to_block(after_block);
10791075

10801076
res.to_rvalue()
10811077
}

0 commit comments

Comments
 (0)