Implement Local and TryCatch lowering in MirBuilder

Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-13 07:13:53 +00:00
parent 3b040f1587
commit ba568f7dfb
3 changed files with 110 additions and 28 deletions

View File

@ -228,11 +228,30 @@ impl MirVerifier {
while let Some(current) = worklist.pop() {
if reachable.insert(current) {
if let Some(block) = function.blocks.get(&current) {
// Add normal successors
for successor in &block.successors {
if !reachable.contains(successor) {
worklist.push(*successor);
}
}
// Add exception handler blocks as reachable
for instruction in &block.instructions {
if let super::MirInstruction::Catch { handler_bb, .. } = instruction {
if !reachable.contains(handler_bb) {
worklist.push(*handler_bb);
}
}
}
// Also check terminator for exception handlers
if let Some(ref terminator) = block.terminator {
if let super::MirInstruction::Catch { handler_bb, .. } = terminator {
if !reachable.contains(handler_bb) {
worklist.push(*handler_bb);
}
}
}
}
}
}