Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dependency tracking for dead code elimination #36

Open
RyanGlScott opened this issue Mar 29, 2023 · 0 comments
Open

Improve dependency tracking for dead code elimination #36

RyanGlScott opened this issue Mar 29, 2023 · 0 comments

Comments

@RyanGlScott
Copy link
Contributor

Currently, dependency tracking for mir-json-dce's dead code elimination is implemented in a very hacky way. One of the more obvious symptoms is here:

mir-json/src/lib_util.rs

Lines 190 to 195 in 5d697d5

JsonValue::String(ref s) => {
if s.contains("::") {
let id2 = self.intern.intern(s.into());
self.dep_map.entry(id).or_insert_with(HashSet::new).insert(id2);
}
},

The idea is that only names that contain :: are eligible for dependency tracking, which is why we check for it here. For instance if we see {"name": "foo::bar"} in one place and {"kind": "call", "fn": "foo::bar"} in another, then the second depends on the first. This check also filters out names like "call" in that example, which we do not want to track.

The downside, of course, is that you have to ensure that all names that you care about actually do contain ::, or else unexpected things will happen. In my case, it caused the name alloc$0 to not appear at all in a key part of the JSON!

We should reimplement dependency tracking in a way that avoids the need for this hack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant