Skip to content

Commit cc87115

Browse files
committed
We don't need to check kill set before adding to gen set
Since we're processing instructions in reverse and our IR is SSA, we can't have entries in the kill set
1 parent ab8fd57 commit cc87115

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

zjit/src/backend/lir.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,7 @@ impl Assembler
23082308
/// Return a traversal of the block graph in reverse post-order.
23092309
pub fn rpo(&self) -> Vec<BlockId> {
23102310
let entry_blocks: Vec<BlockId> = self.basic_blocks.iter()
2311-
.filter(|block| block.entry)
2311+
.filter(|block| block.is_entry)
23122312
.map(|block| block.id)
23132313
.collect();
23142314
let mut result = self.po_from(entry_blocks);
@@ -2393,13 +2393,6 @@ impl Assembler
23932393
let kill_set = &mut kill_sets[block_id.0];
23942394
let gen_set = &mut gen_sets[block_id.0];
23952395

2396-
// Add block parameters to kill set FIRST (they're defined at block entry)
2397-
for param in &block.parameters {
2398-
if let Opnd::VReg { idx, .. } = param {
2399-
kill_set.insert(*idx);
2400-
}
2401-
}
2402-
24032396
// Iterate over instructions in reverse
24042397
for insn in block.insns.iter().rev() {
24052398
// If the instruction has an output that is a VReg, add to kill set
@@ -2410,15 +2403,21 @@ impl Assembler
24102403
}
24112404

24122405
// For all input operands that are VRegs, add to gen set
2413-
// (only if not already in kill set)
24142406
for opnd in insn.opnd_iter() {
24152407
if let Opnd::VReg { idx, .. } = opnd {
2416-
if !kill_set.get(*idx) {
2417-
gen_set.insert(*idx);
2418-
}
2408+
assert!(!kill_set.get(*idx));
2409+
gen_set.insert(*idx);
24192410
}
24202411
}
24212412
}
2413+
2414+
// Add block parameters to kill set
2415+
for param in &block.parameters {
2416+
if let Opnd::VReg { idx, .. } = param {
2417+
kill_set.insert(*idx);
2418+
}
2419+
}
2420+
24222421
}
24232422

24242423
(kill_sets, gen_sets)
@@ -2431,7 +2430,7 @@ impl Assembler
24312430
// Get blocks in postorder
24322431
let po_blocks = {
24332432
let entry_blocks: Vec<BlockId> = self.basic_blocks.iter()
2434-
.filter(|block| block.entry)
2433+
.filter(|block| block.is_entry)
24352434
.map(|block| block.id)
24362435
.collect();
24372436
self.po_from(entry_blocks)

0 commit comments

Comments
 (0)