Skip to content

Fix #175: declare int (not i1) runtime params to match C ABI#187

Open
Emad-Mahmodi wants to merge 1 commit into
eurecom-s3:masterfrom
Emad-Mahmodi:fix/issue-175-runtime-int-types
Open

Fix #175: declare int (not i1) runtime params to match C ABI#187
Emad-Mahmodi wants to merge 1 commit into
eurecom-s3:masterfrom
Emad-Mahmodi:fix/issue-175-runtime-int-types

Conversation

@Emad-Mahmodi

Copy link
Copy Markdown

Fixes #175 (follow-up to #83).

Audited every int1T parameter in compiler/Runtime.cpp against the C signatures in runtime/include/RuntimeCommon.h. The functions whose C parameter is int were declared with i1, the same mismatch as #83 — the callee reads 32 bits while the compiler passes one, so the high bits can be dirty:

  • _sym_build_float (int is_double)
  • _sym_build_int_to_float (int is_double, int is_signed)
  • _sym_build_float_to_float (int to_double)
  • _sym_build_bits_to_float (int to_double)

This declares those parameters as i32 and passes the flags as i32 at the call sites.

The remaining i1 parameters correspond to C bool arguments (_sym_build_bool, the overflow helpers, _sym_read_memory / _sym_write_memory, _sym_build_insert / _sym_build_extract). For bool, clang already lowers to i1, the width matches, and the callee observes only one bit, so these are not affected by the #83 mechanism and are left unchanged. _sym_push_path_constraint is handled in #186.

Verified behavior-preserving: a float-heavy program (float/double compares, int→float, float→float, bitcast) produces identical diverging inputs before and after, and instruments without verifier errors.

Several runtime functions whose C signature takes an int were declared to the compiler with a 1-bit integer (int1T) -- the same i1-vs-int mismatch as eurecom-s3#83. Affected: _sym_build_float (is_double), _sym_build_int_to_float (is_double, is_signed), _sym_build_float_to_float and _sym_build_bits_to_float (to_double). Declare these parameters as i32 and pass the flags as i32 at the call sites.

The remaining i1 parameters correspond to C bool arguments, whose width already matches (clang lowers bool to i1) and where the callee observes only one bit, so they are unaffected. _sym_push_path_constraint is addressed separately in eurecom-s3#186. Behavior-preserving (identical diverging inputs on a float-heavy test).
@Emad-Mahmodi Emad-Mahmodi force-pushed the fix/issue-175-runtime-int-types branch from 883f6bc to 243430f Compare June 20, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible type mismatch for runtime functions

1 participant