Normalize passes keep spans and clean warnings

This commit is contained in:
nyash-codex
2025-11-24 15:02:51 +09:00
parent 466e636af6
commit da1a5558e5
40 changed files with 547 additions and 362 deletions

View File

@ -9,15 +9,15 @@ pub fn check_weakref_and_barrier(function: &MirFunction) -> Result<(), Vec<Verif
let mut def_map: std::collections::HashMap<ValueId, (BasicBlockId, usize, &MirInstruction)> =
std::collections::HashMap::new();
for (bid, block) in &function.blocks {
for (idx, inst) in block.all_instructions().enumerate() {
if let Some(dst) = inst.dst_value() {
def_map.insert(dst, (*bid, idx, inst));
for (idx, sp) in block.all_spanned_instructions_enumerated() {
if let Some(dst) = sp.inst.dst_value() {
def_map.insert(dst, (*bid, idx, sp.inst));
}
}
}
for (bid, block) in &function.blocks {
for (idx, inst) in block.all_instructions().enumerate() {
match inst {
for (idx, sp) in block.all_spanned_instructions_enumerated() {
match sp.inst {
MirInstruction::WeakRef {
op: crate::mir::WeakRefOp::Load,
value,
@ -103,11 +103,10 @@ pub fn check_barrier_context(function: &MirFunction) -> Result<(), Vec<Verificat
let mut errors = Vec::new();
for (bid, block) in &function.blocks {
let mut insts: Vec<(usize, &MirInstruction)> =
block.instructions.iter().enumerate().collect();
if let Some(term) = &block.terminator {
insts.push((usize::MAX, term));
}
let insts: Vec<(usize, &MirInstruction)> = block
.all_spanned_instructions_enumerated()
.map(|(i, sp)| (i, sp.inst))
.collect();
for (idx, inst) in &insts {
let is_barrier = matches!(
inst,