Skip to content

Verify most of the mid-end#105

Draft
avanhatt wants to merge 2 commits into
mainfrom
veri-midend
Draft

Verify most of the mid-end#105
avanhatt wants to merge 2 commits into
mainfrom
veri-midend

Conversation

@avanhatt

Copy link
Copy Markdown
Owner

No description provided.

Comment on lines +219 to +223
// Rebuild the equality sets with the reindex applied, so that the
// deleted `target` binding is replaced by `replace`. Without this, a
// deleted binding can linger in the disjoint set (possibly as a set
// representative), and `equalities()` would later return a reference to
// a binding that no longer exists.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are there potentially any lingering bugs in the existing verification due to this?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

No observable change in the veri results on other targets, so not that I know of.

Comment thread cranelift/isle/veri/veri/src/spec.rs Outdated
// other compilation units; skip those rather than erroring.
let Some(term_id) = termenv.get_term_by_name(tyenv, &spec.term) else {
log::debug!(
"skipping spec for term {name} not declared in this compilation",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tend to be nervous about silencing warnings like this. The existing warning serves as a good linter, and without it we could end up with stale specs/attrs for terms that have been deleted or renamed.

Is this unavoidable, or could we fix it by rearranging the specs/attrs into a different set of shared files?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Good point, removing!

Comment on lines +9 to +13
(spec (simplify arg)
(provide
(if relax_nan
(fp_equiv! result arg)
(= result arg))))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm a bit torn here. On one hand this is much simpler than other ways I could think of making this change. On the other hand, I wonder if this sets up a potential future footgun: is it possible that a float-to-int conversion in a rule could end up with relax_nan true causing a fp_equiv! on integer values? If so, is there a way we could prevent that in future?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Discussed in meeting, adding comment but keeping for now

Comment on lines +156 to +161
Binding::Iterator { source } => {
// The yielded element has the source term's element type, which we
// model as its (single) return type.
let source_binding = lookup_binding(*source);
binding_type(&source_binding, term_id, prog, lookup_binding)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is the mental model here? We are verifying properties that would hold of any return from a multi term, but not attempting to verify how many returns it has?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Correct. The one mid-end term that yields an iterator as a multi-term is truthy, which could e.g. match on ineg x and bmask y in the same e-class and trigger a rule firing on both. The correctness condition is for the rewrite to be sound for any return, not the number of returns.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll need more time to look through this, but my first thought is whether some of the helper macros in here belong in the shared spec macros rather than opt.isle.

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.

2 participants