@@ -288,53 +288,72 @@ def _extract_alloc_id(operands: KInner) -> int | None:
288288 return None
289289
290290
291- def _annotate_unknown_function (k_cell : KInner , smir_info : SMIRInfo ) -> list [str ]:
292- """If the k cell is `#setUpCalleeData` for `** UNKNOWN FUNCTION **` , return annotation lines with decoded info."""
291+ def _annotate_nobody_function (k_cell : KInner , smir_info : SMIRInfo ) -> list [str ]:
292+ """If the k cell is `#setUpCalleeData` for a `noBody` callee , return annotation lines with decoded info."""
293293
294294 from .alloc import Allocation , AllocId , AllocInfo , Memory
295295 from .linker import _demangle
296296
297- setup_call_label = '#setUpCalleeData(_,_,_)_KMIR-CONTROL-FLOW_KItem_MonoItemKind_Operands_Span'
297+ setup_call_labels = {
298+ '#setUpCalleeData(_,_,_)_KMIR-CONTROL-FLOW_KItem_MonoItemKind_Operands_Span' ,
299+ '#setUpCalleeData(_,_)_KMIR-CONTROL-FLOW_KItem_MonoItemKind_Operands' ,
300+ }
298301
299302 annotations : list [str ] = []
300303
301304 match k_cell :
302305 case KSequence (items = (KApply (label = KLabel (name = label_name ), args = args ), * _)) | KApply (
303306 label = KLabel (name = label_name ), args = args
304- ) if (label_name == setup_call_label ):
307+ ) if (label_name in setup_call_labels ):
305308 match args :
306309 case [
307310 KApply (
308311 label = KLabel (name = 'MonoItemKind::MonoItemFn' ),
309312 args = [
310313 KApply (args = [KToken (token = symbol_name )]),
311314 KApply (label = KLabel (name = 'defId(_)_BODY_DefId_Int' ), args = [KToken (token = def_id_str )]),
312- _ ,
315+ KApply ( label = KLabel ( name = 'noBody_BODY_MaybeBody' ), args = []) ,
313316 ],
314317 ),
315318 operands ,
316319 KApply (label = KLabel (name = 'span' ), args = [KToken (token = span_str )]),
317- ] if (
318- symbol_name == '\" ** UNKNOWN FUNCTION **\" '
319- ):
320+ ]:
320321 def_id = int (def_id_str )
321322 span = int (span_str )
323+ case [
324+ KApply (
325+ label = KLabel (name = 'MonoItemKind::MonoItemFn' ),
326+ args = [
327+ KApply (args = [KToken (token = symbol_name )]),
328+ KApply (label = KLabel (name = 'defId(_)_BODY_DefId_Int' ), args = [KToken (token = def_id_str )]),
329+ KApply (label = KLabel (name = 'noBody_BODY_MaybeBody' ), args = []),
330+ ],
331+ ),
332+ operands ,
333+ ]:
334+ def_id = int (def_id_str )
335+ span = None
322336 case _:
323337 return []
324338 case _:
325339 return []
326340
327- # Use extracted DefId for function name
328- func_sym = smir_info .function_symbols .get (def_id , {})
329- if name := func_sym .get ('NormalSym' ) or func_sym .get ('IntrinsicSym' ):
341+ # Prefer concrete symbol from the term; for unresolved placeholders, fall back to DefId lookup.
342+ if symbol_name == '\" ** UNKNOWN FUNCTION **\" ' :
343+ func_sym = smir_info .function_symbols .get (def_id , {})
344+ display_name = func_sym .get ('NormalSym' ) or func_sym .get ('IntrinsicSym' )
345+ else :
346+ display_name = symbol_name .strip ('\" ' )
347+
348+ if display_name :
330349 try :
331- name = _demangle (name )
350+ display_name = _demangle (display_name )
332351 except Exception :
333352 pass
334- annotations .append (f' >> function: { name } ' )
353+ annotations .append (f' >> function: { display_name } ' )
335354
336355 # Use extracted Span for call site
337- if span in smir_info .spans :
356+ if span is not None and span in smir_info .spans :
338357 path , start_row , start_col , _ , _ = smir_info .spans [span ]
339358 annotations .append (f' >> call span: { path } :{ start_row } :{ start_col } ' )
340359
@@ -379,7 +398,7 @@ def render_leaf_k_cells(proof: APRProof, cterm_show: CTermShow, smir_info: SMIRI
379398 lines .extend (f' { k_line } ' for k_line in k_lines )
380399
381400 if smir_info is not None and k_cell is not None :
382- annotations = _annotate_unknown_function (k_cell , smir_info )
401+ annotations = _annotate_nobody_function (k_cell , smir_info )
383402 lines .extend (annotations )
384403
385404 if idx != len (leaves ) - 1 :
0 commit comments