Skip to content

Shared: Prepare model generation for C++ adoption #19273

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

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Apr 10, 2025

This PR slightly generalizes the model generation input signature to allow for a smooth C++ adoption:

  • 732fcbf moves the asParameter out of the NodeExtended signature. This is necessary because the return type of C++'s Node.asParameter is different from the actual parameter nodes we use inside dataflow.
  • Likewise, c484945 moves the getEnclosingCallable out of the NodeExtended for similar reasons. I also moved getAsExprEnclosingCallable for symmetry.
  • ea3bb8c adds a hook to customize the ReturnValue string for ValueReturnKinds. This necessary because C++ has ReturnValue, ReturnValue[*], ReturnValue[**], etc, for returning p, *p, **p from a function.

Additionally, I fixed a potential cartesian product in a1dc874 that I was hitting when testing MaD on a large C++ repository internally at Microsoft.

Commit-by-commit review recommended.

@michaelnebel does this need additional testing other than CI? And if so, how do I go about doing that?

@github-actions github-actions bot added C# Java Rust Pull requests that update Rust code labels Apr 10, 2025
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Apr 10, 2025
@michaelnebel
Copy link
Contributor

michaelnebel commented Apr 10, 2025

does this need additional testing other than CI? And if so, how do I go about doing that?

Yes, we should probably use the mad-queries suites in DCA for Java and C# to check performance (and stability of constructed models). These also print some model diff output as well as measure the performance. For technical reasons the DCA experiment needs the query suite both as the query suite being executed but also as "uninterpreted" queries.

If you want to add a similar DCA suite for C++ we might need to make some changes to DCA to support the model generator related summaries for C++?

I will start some experiments for C# (for .NET Runtime) and Java (SDK). 😄

@MathiasVP
Copy link
Contributor Author

If you want to add a similar DCA suite for C++ we might need to make some changes to DCA to support the model generator related summaries for C++?

Uh, yeah that sounds good. We can maybe discuss that once we've got this merged and #19274 (at which point I can actually open a PR that implements ModelGeneratorInputSig.

Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

Fantastic!

@@ -687,7 +694,7 @@ module MakeModelGenerator<
private DataFlow::ParameterNode parameter;

ContentDataFlowSummaryTargetApi() {
count(string input, string output |
strictcount(string input, string output |
Copy link
Contributor

Choose a reason for hiding this comment

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

Uh, nice catch!

@michaelnebel
Copy link
Contributor

@MathiasVP : I ran the modelgenerator on dotnet/runtime for C# and on jdk17 for Java and it works fine; Don't let the DCA timeout block merging this PR.

@MathiasVP MathiasVP marked this pull request as ready for review April 11, 2025 14:22
@MathiasVP MathiasVP requested review from a team as code owners April 11, 2025 14:22
@MathiasVP
Copy link
Contributor Author

@MathiasVP : I ran the modelgenerator on dotnet/runtime for C# and on jdk17 for Java and it works fine; Don't let the DCA timeout block merging this PR.

Thanks for checking 🙇 I'll go ahead and hit the Big Green Button then 🚀

@MathiasVP MathiasVP merged commit 11aef70 into github:main Apr 11, 2025
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# Java no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants