Skip to content

Fix call graph with respect to constants. #11014

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

Merged
merged 2 commits into from
Feb 25, 2021
Merged

Conversation

chriseth
Copy link
Contributor

Fixes #11007

@chriseth chriseth requested a review from cameel February 25, 2021 10:51
@chriseth
Copy link
Contributor Author

@cameel can you add tests to this, please?

@cameel
Copy link
Member

cameel commented Feb 25, 2021

Sure.

@cameel
Copy link
Member

cameel commented Feb 25, 2021

Tests ready. Unfortunately they don't pass so it looks like the fix is not enough. It fixes constants but for immutables, ordinary variables or even referencing the selector in a function body an edge to the internal dispatch is still being added.

@chriseth Should I take it over and fix these cases?

@chriseth
Copy link
Contributor Author

@cameel can you summarize the problems? Immutables should have the same behaviour as regular state variables. The expression A.g.selector should add an edge from the dispatch to g, but not to he dispatch. I think in the IR codegen, we even generated code for g

@cameel
Copy link
Member

cameel commented Feb 25, 2021

Sorry, it's actually an edge from the dispatch, not to the dispatch that is being added.

So anyway, the problems I was referring to were just all of these adding these edges from dispatch:

bytes4 immutable pubImmutable = Base.pub.selector;
bytes4 pubVar = Base.pub.selector;
return (Base.ext.selector, Base.pub.selector);

The functions are not being called here and I think you can't call them internally via the bytes4 variable that contains the selector? So I thought they should not be in the graph.

But you have a point about the IR codegen. I think it does add them to the dispatch when it's visiting MemberAccess. In that case I'll change the test expectations to expect the edge from dispatch.

@cameel cameel force-pushed the fixConstantsCallGraph branch from 70fa50f to 5dc0dce Compare February 25, 2021 13:25
@cameel
Copy link
Member

cameel commented Feb 25, 2021

@chriseth Expectations updated.

@cameel
Copy link
Member

cameel commented Feb 25, 2021

I have also pushed a fixup that fixes the case found by @bshastry in #11014 (comment)

@chriseth
Copy link
Contributor Author

Looks good! Please rebaes.

@cameel cameel force-pushed the fixConstantsCallGraph branch from 5dc0dce to 186d14d Compare February 25, 2021 15:01
@cameel
Copy link
Member

cameel commented Feb 25, 2021

Rebased and squashed.

@chriseth
Copy link
Contributor Author

Approving.

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.

[Sol->Yul] ICE because "No code generated for function even though it is not a constructor."
3 participants