Skip to content

Commit 62e9b50

Browse files
committed
Remove current_block field of CodegenCx
This field often had the wrong value when using multiple builders at the same time.
1 parent 07afdb8 commit 62e9b50

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/builder.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,7 @@ impl<'gcc, 'tcx> BackendTypes for Builder<'_, 'gcc, 'tcx> {
379379

380380
impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
381381
fn build(cx: &'a CodegenCx<'gcc, 'tcx>, block: Block<'gcc>) -> Self {
382-
let bx = Builder::with_cx(cx, block);
383-
*cx.current_block.borrow_mut() = Some(block);
384-
bx
382+
Builder::with_cx(cx, block)
385383
}
386384

387385
fn llbb(&self) -> Block<'gcc> {
@@ -399,7 +397,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
399397
}
400398

401399
fn switch_to_block(&mut self, block: Self::BasicBlock) {
402-
*self.cx.current_block.borrow_mut() = Some(block);
403400
self.block = block;
404401
}
405402

src/context.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ pub struct CodegenCx<'gcc, 'tcx> {
3131
pub codegen_unit: &'tcx CodegenUnit<'tcx>,
3232
pub context: &'gcc Context<'gcc>,
3333

34-
// TODO(antoyo): First set it to a dummy block to avoid using Option?
35-
pub current_block: RefCell<Option<Block<'gcc>>>,
34+
// TODO(bjorn3): First set it to a dummy function to avoid using Option?
3635
pub current_func: RefCell<Option<Function<'gcc>>>,
3736
pub normal_function_addresses: RefCell<FxHashSet<RValue<'gcc>>>,
3837

@@ -177,7 +176,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
177176
check_overflow,
178177
codegen_unit,
179178
context,
180-
current_block: RefCell::new(None),
181179
current_func: RefCell::new(None),
182180
normal_function_addresses: Default::default(),
183181
functions: RefCell::new(functions),

0 commit comments

Comments
 (0)