Skip to content

Map cells with static data for LLVM kompile#1084

Merged
automergerpr-permission-manager[bot] merged 28 commits into
masterfrom
mk/maybe-map-lookup
May 15, 2026
Merged

Map cells with static data for LLVM kompile#1084
automergerpr-permission-manager[bot] merged 28 commits into
masterfrom
mk/maybe-map-lookup

Conversation

@mariaKt
Copy link
Copy Markdown
Collaborator

@mariaKt mariaKt commented May 9, 2026

This PR introduces a dual lookup mechanism for static data, using a MaybeMap sort, aiming to avoid per-program LLVM kompile in concrete execution. Program-specific data (functions, types, allocations) is stored in Map cells for LLVM execution, while the existing no-evaluators Kore functions are preserved for the Haskell/booster backend.

Status

Both LLVM and Haskell backends work. Zero regressions on the UI test suite with the LLVM backend (1162/1162 baseline). Zero regressions on the UI test suite with the Haskell backend as well. LLVM backend execution ~13x faster (3h vs ~38h, with with 2 workers). Haskell backend execution around the same (10.5 h vs 10 h, with 2 workers again).

Commits

  • Add MaybeMap sort (noMap | someMap(Map)) and new <functions>, <types>, <memory> cells to the configuration.
  • Rename existing lookupFunction/lookupTy/lookupAlloc to lookupFunctionKore/lookupTyKore/lookupAllocKore (keeping [no-evaluators]).
  • Add map-based lookup functions (lookupFunctionMap, lookupTyMap, lookupAllocMap) using orDefault for missing keys.
  • Add top-level wrapper functions lookupFunction(MaybeMap, Ty) etc. that dispatch to Kore or Map versions.
  • Update all rewrite rules in kmir.md and rt/data.md to read the new cells and use the wrapper functions.
  • Add symbol(MaybeMap::noMap) and symbol(MaybeMap::someMap) attributes for clean Python integration.
  • Build the map cell contents in Python (_make_smir_maps) and skip LLVM kompile in concrete execution.
  • Strip map cell contents from Kore output before pretty printing (replace with noMap via top_down KORE traversal).
  • Explicitly initialize the map cells to noMap in the symbolic call config to have concrete values instead of unbound Kore variables.
  • Split top-level lookup functions into concrete (regular [function]) and symbolic ([no-evaluators]) using markdown selectors. In concrete execution, dispatch to map lookups; in symbolic execution, per-program axioms bridge to lookupXKore.
  • Generate bridge axioms for lookupFunction, lookupTy, lookupAlloc, and #getBlocks to delegate from the [no-evaluators] wrapper to lookupXKore in the Haskell definition.
  • Convert all [no-evaluators] functions that call lookupTyKore directly to concrete/symbolic split with MaybeMap parameter: #getBlocks, readTyConstInt, #staticArrayLenBits, getTyOf, #metadataSize, #metadataSizeAux, #typeProjection, #pointeeProjection, #pointeeProjectionTarget, getArrayElemTypeInfo, #lookupMaybeTy, #sizeOf, #alignOf, #isStaticU8Array, #convertMetadata, #projectedCallTy, #extractOperandType, #decodeValue, #neededBytesForOffsets, #decodeFieldsWithOffsets, #elemSize, #decodeEnumDirectFields, #decodeArrayAllocation, #decodeArrayElements, #decodeSliceAllocation. (multiple commits)
  • Update expected test output for new configuration cells.
  • Fix test infrastructure for shared LLVM definition (test_decode_value, test_cli_prove_add_module_*).

@mariaKt
Copy link
Copy Markdown
Collaborator Author

mariaKt commented May 9, 2026

Relevant discussion on slack

@mariaKt mariaKt force-pushed the mk/maybe-map-lookup branch 2 times, most recently from e4ad90c to 84f438d Compare May 12, 2026 23:30
@mariaKt mariaKt marked this pull request as ready for review May 14, 2026 16:00
mariaKt added 26 commits May 14, 2026 11:05
Due to it calling loopupFunction in its boby while being no-evaluators
Callsites not in [no-evaluators] functions updated.

Temporary syntax-only fixes for callsites inside [no-evaluators] functions.
…ets, and #elemSize.

Temporary noMap fixes for the callsites in functions with [no-evaluators]
mariaKt added 2 commits May 14, 2026 11:05
- test_cli_prove_add_module_*: added new cells in rule in corresponding module
- test_cli_show_to_module: updated expected output (three new cells expected)
- test_decode_value: the LLVM definition is now shared (not per-program), so the test could not compile a per-program definition. Updated fixture to use KMIR.definition_dir directly. Also, #decodeValue now takes MaybeMap as first argument, so the Kore template and to_pattern were updated to pass the types map built from TEST_SMIR.
@mariaKt mariaKt force-pushed the mk/maybe-map-lookup branch from 84f438d to 75773fe Compare May 14, 2026 16:07
@mariaKt mariaKt requested review from dkcumming and ehildenb May 14, 2026 16:48
Copy link
Copy Markdown
Collaborator

@dkcumming dkcumming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice I like it a lot! I went through each commit and it all makes sense. It is unfortunate there needs to be so much duplication of code for the symbolic and concrete cases. Maybe there would be some solution for that in the future, but it is not too much of a cost to bear for now for the massive performance increase. I think there is a way to remove printing the cells entirely too, not just with noMap replaced. But that is not a big deal for now either.

@automergerpr-permission-manager automergerpr-permission-manager Bot merged commit 1cc5dbd into master May 15, 2026
12 checks passed
@automergerpr-permission-manager automergerpr-permission-manager Bot deleted the mk/maybe-map-lookup branch May 15, 2026 14:29
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.

2 participants