Fix incoherent CallGraph build in ProcedureInlining#931
Merged
Conversation
CallGraph is stored in CachedAnalyses of the Core transformation monad state (CoreTransformState), and it is supposed to be correctly incrementarily updated during transformations (e.g., when call is eliminated, etc). However, ProcedureInlining was incorrectly updating this. The reason was as follows: the CachedAnalyses is (correctly) eagerly updated after every call is inlined, whereas the program that ProcedureInlining was actually using was not being updated. ProcedureInlining is supposed to look at the intermediate program after inlinings are happened, because that is exactly the program that CachedAnalyses stores for. In theory, this can make ProcedureInlining more aggressive: if f1 is calling f2 and f2 is calling f3 and f3 is calling f4, * After this patch: during one round of ProcedureInlining, if f2 -> f3 in f2 happened to be inlined first, inlining f1->f2 will see the latest update and introduce f1->f4 * Before this patch: one round of ProcedureInlining of f1->f2 would have always introduced f1->f3 because ProcedureInlining always saw the "old" program. However, in practice, this doesn't matter because we are using the 'roots' mode during bugFinding (and ProcedureInlining is only called from bugFinding mode) and calls whose callers are the roots are only of concerns.
tautschnig
reviewed
Apr 16, 2026
tautschnig
approved these changes
Apr 16, 2026
shigoel
reviewed
Apr 16, 2026
shigoel
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CallGraph is stored in CachedAnalyses of the Core transformation monad state (CoreTransformState), and it is supposed to be correctly incrementarily updated during transformations (e.g., when call is eliminated, etc). However, ProcedureInlining was incorrectly updating this.
The reason was as follows: the CachedAnalyses is (correctly) eagerly updated after every call is inlined, whereas the program that ProcedureInlining was actually using was not being updated. ProcedureInlining is supposed to look at the intermediate program after inlinings are happened, because that is exactly the program that CachedAnalyses stores for.
In theory, this can make ProcedureInlining more aggressive: if f1 is calling f2 and f2 is calling f3 and f3 is calling f4,
However, in practice, this doesn't matter because we are using the 'roots' mode during bugFinding (and ProcedureInlining is only called from bugFinding mode) and calls whose callers are the roots are only of concerns.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.