SMT2: disambiguate element-address functions by index type#9064
Open
tautschnig wants to merge 1 commit into
Open
SMT2: disambiguate element-address functions by index type#9064tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
smt2_convt names the helper function emitted for ID_element_address as "element-address-<type2id(result)>", keyed on the result (pointer) type only. When two element_address expressions share a result type but have different index types, both the declaration and the application reuse the same function name with different argument sorts, so an SMT solver rejects the second application with an "unknown constant" sort-mismatch error. Include type2id(index_type) in the function name in both the application (convert_expr) and the declaration (find_symbols), and build the element size argument in an integer index type when the index type is not itself an integer/bitvector, so the declared and applied sorts always agree. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Disambiguates SMT helper functions for ID_element_address by including the index type in the emitted function name, preventing SMT sort-mismatch errors when the same result type is used with different index types.
Changes:
- Include
type2id(index_type)in theelement-address-...helper name for both declaration and application. - Ensure the “element size” argument is built with an integer sort (fallback to
c_index_type()/ unit size as needed) so declared/applied sorts match.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1926
to
+1940
| // The size/offset arithmetic requires an integer index type. Heap arrays | ||
| // keyed by a non-integer type (Strata `Map Ref _`) or with mathematical | ||
| // element types have neither a sensible byte size nor an integer index; | ||
| // fall back to an integer index type and unit size to avoid building a | ||
| // constant of a struct type. | ||
| const typet &idx_t = element_address_expr.index().type(); | ||
| const bool int_index = | ||
| idx_t.id() == ID_unsignedbv || idx_t.id() == ID_signedbv || | ||
| idx_t.id() == ID_bv || idx_t.id() == ID_integer || | ||
| idx_t.id() == ID_c_enum || idx_t.id() == ID_c_enum_tag; | ||
| const typet size_target = int_index ? idx_t : c_index_type(); | ||
| const exprt element_size_expr = | ||
| element_size_expr_opt.has_value() | ||
| ? *element_size_expr_opt | ||
| : static_cast<exprt>(from_integer(1, size_target)); |
Comment on lines
+1931
to
+1936
| const typet &idx_t = element_address_expr.index().type(); | ||
| const bool int_index = | ||
| idx_t.id() == ID_unsignedbv || idx_t.id() == ID_signedbv || | ||
| idx_t.id() == ID_bv || idx_t.id() == ID_integer || | ||
| idx_t.id() == ID_c_enum || idx_t.id() == ID_c_enum_tag; | ||
| const typet size_target = int_index ? idx_t : c_index_type(); |
Comment on lines
+5992
to
+5993
| irep_idt function = "element-address-" + type2id(expr.type()) + "_" + | ||
| type2id(to_element_address_expr(expr).index().type()); |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9064 +/- ##
===========================================
- Coverage 80.68% 80.68% -0.01%
===========================================
Files 1714 1714
Lines 189501 189517 +16
Branches 73 73
===========================================
+ Hits 152902 152912 +10
- Misses 36599 36605 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
smt2_convt names the helper function emitted for ID_element_address as "element-address-<type2id(result)>", keyed on the result (pointer) type only. When two element_address expressions share a result type but have different index types, both the declaration and the application reuse the same function name with different argument sorts, so an SMT solver rejects the second application with an "unknown constant" sort-mismatch error.
Include type2id(index_type) in the function name in both the application (convert_expr) and the declaration (find_symbols), and build the element size argument in an integer index type when the index type is not itself an integer/bitvector, so the declared and applied sorts always agree.