Skip to content

fix(kompile): map linked NormalSym functions to monoItemFn(noBody)#953

Merged
automergerpr-permission-manager[bot] merged 15 commits intomasterfrom
jh/fix-normalsym-mapping
Mar 5, 2026
Merged

fix(kompile): map linked NormalSym functions to monoItemFn(noBody)#953
automergerpr-permission-manager[bot] merged 15 commits intomasterfrom
jh/fix-normalsym-mapping

Conversation

@Stevengre
Copy link
Contributor

@Stevengre Stevengre commented Feb 28, 2026

Summary

  • Generate MonoItemKind::MonoItemFn(symbol(...), defId(...), noBody) for linked NormalSym entries that are present in function_symbols but missing from items.
  • Keep function resolution on concrete linked symbols instead of falling back to "** UNKNOWN FUNCTION **" for bodyless linked functions.
  • Refresh affected integration/show fixtures and normalize panic symbol hash suffixes in fixture comparison to keep snapshot output stable.
  • Preserve readable kmir show --statistics --leaves annotations for noBody callees (>> function, >> call span, >> message) even after replacing "** UNKNOWN FUNCTION **" with concrete symbols.

Context

In multi-crate SMIR, linked external functions can exist in function_symbols but not in local items (no local body). Before this change, that gap could leave lookupFunction(Ty) without a generated monoItemFn equation.

Red vs Green

RED (actual stuck shape in show fixtures):

#setUpCalleeData(
  monoItemFn(... name: symbol("** UNKNOWN FUNCTION **"), id: defId(38), body: noBody),
  ...
)

This is the unresolved-function path.

GREEN (after fix):

#setUpCalleeData(
  monoItemFn(... name: symbol("_ZN4core9panicking5panic17h<hash>E"), id: defId(38), body: noBody),
  ...
)

The same path now resolves to a concrete linked symbol instead of "** UNKNOWN FUNCTION **".

@Stevengre Stevengre self-assigned this Mar 3, 2026
Stevengre added 13 commits March 3, 2026 11:59
Linked NormalSym functions (external crate functions present in SMIR but
without a local body) had no generated monoItemFn equation, falling back
to "** UNKNOWN FUNCTION **". This synthesizes monoItemFn(symbol(...),
defId(...), noBody) for all such symbols, ensuring downstream call
resolution can find them.
…nd match dedup

- Merge two separate function_symbols loops into a single pass in kompile.py
- Promote _normalize_symbol_hashes to module-level in fixtures.py
- Hoist duplicated def_id assignment out of match arms in utils.py
Drop symbol_name capture and dual-path logic; always resolve function
name from smir_info.function_symbols via DefId, matching the original
code path.
K semantics only defines the 3-arg variant; the 2-arg label never
appears in K terms. Removing it also eliminates the span-None path,
setup_call_labels set, and associated scaffolding.
Keep symbol_name capture and wildcard match from master; the only
necessary change is removing the UNKNOWN FUNCTION guard.
@Stevengre Stevengre force-pushed the jh/fix-normalsym-mapping branch from 24a25c7 to fdbdb3a Compare March 3, 2026 04:00
@Stevengre Stevengre marked this pull request as ready for review March 3, 2026 04:01
@Stevengre
Copy link
Contributor Author

I think that it should be good to avoid UNKOWN FUNCTION in the semantics. Therefore, I bring this PR.

@Stevengre Stevengre requested a review from mariaKt March 4, 2026 03:56
@automergerpr-permission-manager automergerpr-permission-manager bot merged commit 8ee9ccf into master Mar 5, 2026
7 checks passed
@automergerpr-permission-manager automergerpr-permission-manager bot deleted the jh/fix-normalsym-mapping branch March 5, 2026 05:21
@dkcumming
Copy link
Collaborator

I know I have gotten to this late, but I want to bring up something related. We are not being consistent between instrinsics and other functions. For IntrinsicSym we demangle the name in the name field of the output of stable-mir-json, but for NormalSym we use the mangled name. @ehildenb had this PR converting to using the mangled name, I am not sure why the choice was to use the mangled name over the short name was used but I am going to guess it is because it is ambiguous which black_box is being called.

image

^^^ Notice black_box and assert_failed ^^^

Ideally I would like use a demangled but qualified name for everything. e.g.:

This would remove ambiguity and stop the need to do regex stuff to strip hashes etc.

Stevengre added a commit that referenced this pull request Mar 10, 2026
- fix(kompile): map linked NormalSym functions to monoItemFn(noBody)
[953](#953)
- fix(rt): generalize direct-tag enum decoding to any variant count and
discriminant
[955](#955)
- fix(rt): closure aggregate + #setTupleArgs fallback
[952](#952)
- fix(rt): bug fix for castKindPtrToPtr
[974](#974)
- fix(rt): repair closure callee setup for iter-eq repro
[957](#957)
dkcumming added a commit to runtimeverification/solana-token that referenced this pull request Mar 10, 2026
- fix(rt): handle fun-type closure env refs in callee setup
[956](runtimeverification/mir-semantics#956)
- fix(decode): accept signed enum tag scalars in _extract_tag
[954](runtimeverification/mir-semantics#954)
- Added check for FunType in setupCalleeClosure
[969](runtimeverification/mir-semantics#969)
- Merge in latest master
[973](runtimeverification/mir-semantics#973)
- fix(kompile): map linked NormalSym functions to monoItemFn(noBody)
[953](runtimeverification/mir-semantics#953)
- fix(rt): generalize direct-tag enum decoding to any variant count and
discriminant
[955](runtimeverification/mir-semantics#955)
- fix(spl-token): encode multisig signers as pubkey aggregates
[958](runtimeverification/mir-semantics#958)
- fix(rt): closure aggregate + #setTupleArgs fallback
[952](runtimeverification/mir-semantics#952)
- fix(rt): bug fix for castKindPtrToPtr
[974](runtimeverification/mir-semantics#974)
- fix(rt): repair closure callee setup for iter-eq repro
[957](runtimeverification/mir-semantics#957)
- Change the number of signers from 11 to 3
[982](runtimeverification/mir-semantics#982)
- Merging latest master into feature/p-token
[981](runtimeverification/mir-semantics#981)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants