Skip to content

Commit

Permalink
Check if value is global before checking value in dfg values
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Jan 17, 2025
1 parent 61459db commit 252ee2b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions compiler/noirc_evaluator/src/ssa/ir/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,18 @@ fn display_block(dfg: &DataFlowGraph, block_id: BasicBlockId, f: &mut Formatter)
/// constant or a function we print those directly.
fn value(dfg: &DataFlowGraph, id: ValueId) -> String {
let id = dfg.resolve(id);
if dfg.is_global(id) {
return format!("g{}", id.to_u32());
}

match &dfg[id] {
Value::NumericConstant { constant, typ } => {
format!("{typ} {constant}")
}
Value::Function(id) => id.to_string(),
Value::Intrinsic(intrinsic) => intrinsic.to_string(),
Value::ForeignFunction(function) => function.clone(),
Value::Param { .. } | Value::Instruction { .. } => {
if dfg.is_global(id) {
format!("g{}", id.to_u32())
} else {
id.to_string()
}
}
Value::Param { .. } | Value::Instruction { .. } => id.to_string(),
Value::Global(_) => {
format!("g{}", id.to_u32())
}
Expand Down

0 comments on commit 252ee2b

Please sign in to comment.