-
Notifications
You must be signed in to change notification settings - Fork 2.1k
C++: Use alias analysis in IR dataflow #16463
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
Draft
MathiasVP
wants to merge
10
commits into
github:main
Choose a base branch
from
MathiasVP:alias-analysis-in-dataflow-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ad2c3e7
C++: Make 'SourceVariable' an abstract class and rename a few predica…
MathiasVP dab7952
C++: Add a 'getNode' predicate on 'Def' to mirror what we have on 'Use'.
MathiasVP fd55e7a
C++: Make 'getSourceVariable' an abstract class instead of 'getBaseSo…
MathiasVP 6a5162a
C++: Rename a few more predicates.
MathiasVP 86a4d34
C++: Remove abstract 'getIndirection' on 'Defimpl' and 'UseImpl'.
MathiasVP 7f8ef6b
C++: Use alias analysis in dataflow.
MathiasVP ac8e9f7
C++: Accept test changes.
MathiasVP 7762acb
C++: Accept query test changes.
MathiasVP 393c100
C++: Add QLDoc.
MathiasVP 743c669
C++: Better caching.
MathiasVP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /** | ||
| * INTERNAL: Do not use. | ||
| * | ||
| * The purpose of this file is to control which cached predicates belong to the same stage. | ||
| * | ||
| * Combining stages can improve performance as we are more likely to reuse shared, non-cached predicates. | ||
| * | ||
| * To make a predicate `p` belong to a stage `A`: | ||
| * - make `p` depend on `A::ref()`, and | ||
| * - make `A::backref()` depend on `p`. | ||
| * | ||
| * Since `A` is a cached module, `ref` and `backref` must be in the same stage, and the dependency | ||
| * chain above thus forces `p` to be in that stage as well. | ||
| * | ||
| * With these two predicates in a `cached module` we ensure that all the cached predicates will be in a single stage at runtime. | ||
| * | ||
| * Grouping stages can cause unnecessary computation, as a concrete query might not depend on | ||
| * all the cached predicates in a stage. | ||
| * Care should therefore be taken not to combine two stages, if it is likely that a query only depend | ||
| * on some but not all the cached predicates in the combined stage. | ||
| */ | ||
|
|
||
| private import cpp | ||
|
|
||
| /** | ||
| * Contains a `cached module` for each stage. | ||
| * Each `cached module` ensures that predicates that are supposed to be in the same stage, are in the same stage. | ||
| * | ||
| * Each `cached module` contain two predicates: | ||
| * The first, `ref`, always holds, and is referenced from `cached` predicates. | ||
| * The second, `backref`, contains references to the same `cached` predicates. | ||
| * The `backref` predicate starts with `1 = 1 or` to ensure that the predicate will be optimized down to a constant by the optimizer. | ||
| */ | ||
| module Stages { | ||
| private import semmle.code.cpp.ir.dataflow.internal.SsaInternalsCommon as SsaInternalsCommon | ||
| private import semmle.code.cpp.ir.implementation.aliased_ssa.internal.AliasedSSA as AliasedSSA | ||
Check warningCode scanning / CodeQL Names only differing by case
AliasedSSA is only different by casing from AliasedSsa that is used elsewhere for modules.
|
||
| private import semmle.code.cpp.ir.implementation.raw.internal.IRConstruction as IRConstruction | ||
|
|
||
| /** | ||
| * The `IR` stage. | ||
| */ | ||
| cached | ||
| module IR { | ||
| /** | ||
| * Always holds. | ||
| * Ensures that a predicate is evaluated as part of the IR stage. | ||
| */ | ||
| cached | ||
| predicate ref() { 1 = 1 } | ||
|
|
||
| /** | ||
| * DONT USE! | ||
| * Contains references to each predicate that use the above `ref` predicate. | ||
| */ | ||
| cached | ||
| predicate backref() { | ||
| 1 = 1 | ||
| or | ||
| IRConstruction::Raw::hasInstruction(_, _) | ||
| or | ||
| SsaInternalsCommon::isUse(_, _, _, _) | ||
| or | ||
| exists(AliasedSSA::getOperandMemoryLocation(_)) | ||
| or | ||
| exists(AliasedSSA::getResultMemoryLocation(_)) | ||
| } | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
Check warning
Code scanning / CodeQL
Acronyms should be PascalCase/camelCase.