-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Operands as IPA types #352
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
Conversation
@rdmarsh2 has been working on various queries and libraries on top of the IR, and has pointed out that having to always refer to an operand of an instruction by the pair of (instruction, operandTag) makes using the IR a bit clunky. This PR adds a new `Operand` IPA type that represents an operand of an instruction. `OperandTag` still exists, but is now an internal type used only in the IR implementation.
4ee405a
to
f278f4f
Compare
I think this is an improvement overall, but it doesn't answer the question I have on #251, the port of the Java sign analysis library. When we port existing libraries to the IR, we need an answer for what the IR equivalent of The new At the other end of the spectrum we have |
@jbj I think your question boils down to "how do we handle inference of new information about a value due to control flow". One approach that works for traditional compilers is to insert a new artificial definition of a value whenever you might learn something about that value due to control flow:
becomes
The Then, you want to handle cases like this:
Here, you'd like to infer the fact that
This makes the inference work correctly, but has the drawback that it becomes more challenging to get back to the original code in order to report a good alert message, because everything is in terms of the temps introduced by CSE. If we don't insert inference operators, we can associate state with individual |
I'm in favor of this approach - we'll want to work with
For the AST side of IR-based libraries, it's necessary that each |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the overall approach is sound, and I'll leave the detailed reviewing/merging to @rdmarsh2. We can continue the discussion about CSE and Expr
-correspondence over Hangouts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small things, but overall it looks good.
cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysis.qll
Show resolved
Hide resolved
cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll
Outdated
Show resolved
Hide resolved
cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll
Outdated
Show resolved
Hide resolved
How does the IR perform after these changes, @dave-bartolomeo? |
@jbj Running |
Add missing `DataFlowImpl2.qll` entry to `identical-files.json`
Kotlin: Use -Xopt-in=kotlin.RequiresOptIn when compiling
@rdmarsh2 has been working on various queries and libraries on top of the IR, and has pointed out that having to always refer to an operand of an instruction by the pair of (instruction, operandTag) makes using the IR a bit clunky. This PR adds a new
Operand
IPA type that represents an operand of an instruction.OperandTag
still exists, but is now an internal type used only in the IR implementation.I'll post performance numbers when I have them.