Skip to content

Emit deterministic output #13

@fitzgen

Description

@fitzgen

The graphviz output is not deterministic because nodes are added to a hash map and then the contents of the hash map are later iterated over. Rusts standard library’s hash maps do not have stable iteration order. This makes the graphviz output unsuitable for use as test expectations/fixtures.

For example:

(I haven’t audited the rest of the code for other occurrences)

I suggest instead either using BTreeMap or collecting the hash map entries into a vec and then sorting it before iteration.

I can send a PR in the next day or so if no one else fixes this before then. Let me know if you prefer one of the above options to another.

Thanks!

Aside: I’ve been having fun experimenting with a little compiler to combine egraphs and a sea-of-nodes ish IR, trying to explore what we are missing in Cranelift land by only bringing the pure subset of the DFG into our egraph. Chris told me y’all were doing something similar, and I saw the eggcc RSVDG stuff in the test directory. Looks pretty neat! Would love to chat sometime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions