Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ca92695

Browse files
committed
Use IndexVec for ebb_map
cc rust-lang#745
1 parent ff1c623 commit ca92695

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/abi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb:
398398

399399
fx.bcx
400400
.ins()
401-
.jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]);
401+
.jump(*fx.ebb_map.get(START_BLOCK).unwrap(), &[]);
402402
}
403403

404404
pub fn codegen_terminator_call<'tcx>(

src/base.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc::ty::adjustment::PointerCast;
2+
use rustc_index::vec::IndexVec;
23

34
use crate::prelude::*;
45

@@ -27,10 +28,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
2728

2829
// Predefine ebb's
2930
let start_ebb = bcx.create_ebb();
30-
let mut ebb_map: HashMap<BasicBlock, Ebb> = HashMap::new();
31-
for (bb, _bb_data) in mir.basic_blocks().iter_enumerated() {
32-
ebb_map.insert(bb, bcx.create_ebb());
33-
}
31+
let ebb_map: IndexVec<BasicBlock, Ebb> = (0..mir.basic_blocks().len()).map(|_| bcx.create_ebb()).collect();
3432

3533
// Make FunctionCx
3634
let pointer_type = cx.module.target_config().pointer_type();

src/common.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc::ty::layout::{Integer, Primitive};
22
use rustc_target::spec::{HasTargetSpec, Target};
3+
use rustc_index::vec::IndexVec;
34

45
use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef};
56

@@ -263,7 +264,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> {
263264
pub mir: &'tcx Body<'tcx>,
264265

265266
pub bcx: FunctionBuilder<'clif>,
266-
pub ebb_map: HashMap<BasicBlock, Ebb>,
267+
pub ebb_map: IndexVec<BasicBlock, Ebb>,
267268
pub local_map: HashMap<Local, CPlace<'tcx>>,
268269

269270
pub clif_comments: crate::pretty_clif::CommentWriter,
@@ -341,7 +342,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
341342
}
342343

343344
pub fn get_ebb(&self, bb: BasicBlock) -> Ebb {
344-
*self.ebb_map.get(&bb).unwrap()
345+
*self.ebb_map.get(bb).unwrap()
345346
}
346347

347348
pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> {

0 commit comments

Comments
 (0)