Skip to content

Conversation

@dbartol
Copy link

@dbartol dbartol commented May 7, 2021

This PR is best reviewed commit-by-commit. It does introduce one consistency check failure, which I believe to be caused by an extractor problem that I'm trying to reduce to a simple repro.

Dave Bartolomeo added 5 commits May 7, 2021 16:03
This commit adds a `PrintAliasAnalysis.qll` module, which can be imported alongside `PrintIR.qll` to annotate those dumps with alias analysis results.
When inserting side effect instructions for argument indirections, we now insert side effects for smart pointers as we would for raw pointers. The address operand of the side effect instruction is  the smart pointer object, which is a bit odd. However, I'd like to think through the design of a more principled solution before doing additional work.

A few new tests are added to the existing IR tests. In addition, the IR tests now `#include` some of the shared STL headers. I've disabled IR dumps for functions from those headers, since they only get in the way of the test cases we intended.
@dbartol dbartol added the C++ label May 7, 2021
@dbartol dbartol requested review from MathiasVP and rdmarsh2 May 7, 2021 21:02
@dbartol dbartol requested review from a team as code owners May 7, 2021 21:02
@github-actions github-actions bot added the C# label May 7, 2021
@dbartol dbartol added the no-change-note-required This PR does not need a change note label May 7, 2021
Comment on lines +252 to +255
"SSA PrintAliasAnalysis": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintAliasAnalysis.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintAliasAnalysis.qll"
],
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the C# version be synced here?

Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

LGTM (assuming Robert's comment is addressed).

@MathiasVP
Copy link
Contributor

It looks like we don't get a WriteSideEffect for the code in this issue because shared_ptr<int> satisfies isDeeplyConstBelow, and so hasDefaultSideEffect only holds for the ptr parameter with isWrite = false.

So I guess we need to use something other than isDeeplyConstBelow for filtering out things that shouldn't have a WriteSideEffect. I did add a PointerWrapper.pointsToConst() predicate that we can use for the PointerWrapper case, at least.

I don't think any of this should block this PR, but we should think of a more robust way of doing this.

@MathiasVP
Copy link
Contributor

MathiasVP commented May 25, 2021

@MathiasVP
Copy link
Contributor

MathiasVP commented May 31, 2021

I've started a CPP-differences here: https://jenkins.internal.semmle.com/job/Changes/job/CPP-Differences/2038/https://jenkins.internal.semmle.com/job/Changes/job/CPP-Differences/2040/

I checked the performance on linux locally and I couldn't reproduce the slowdown.

In the interest of preventing the PR from going stale, I think we should merge it as-is. I don't think any of the comments here are blocking this PR. What do you think @rdmarsh2?

@jbj jbj merged commit 7282ad9 into github:main Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# C++ no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants