Commit Graph

12966 Commits

Author SHA1 Message Date
Nick Rolfe
fc91ff1a69 C++: we now process operands for vacuous destructor calls thru pointers 2018-12-03 12:16:35 +00:00
Dave Bartolomeo
2822d14588 C++: Add missing changes to test_ir.expected 2018-12-02 22:22:34 -08:00
Jonas Jensen
d14cf34cc6 C++: data flow AlwaysTrueUponEntryLoop perf fix
The predicate `AlwaysTrueUponEntryLoop.getARelevantVariable` was very
sensitive to join ordering, and with the 1.19 QL engine it got an
unfortunate join order that made it explode on certain snapshots. With
this change, it goes from taking minutes to taking less than a second on
a libretro-uae snapshot.
2018-12-01 10:07:08 +01:00
Dave Bartolomeo
7eb47f3f82 C++: A few more IR dataflow tweaks
Made `Node::getType()`, `Node::asParameter()`, and `Node::asUninitialized()` operate directly on the IR. This actually fixed several diffs compared to the AST dataflow, because `getType()` wasn't holding for nodes that weren't `Exprs`.

Made `Uninitialized` a `VariableInstruction`. This makes it consistent with `InitializeParameter`.
2018-11-30 16:53:45 -08:00
Dave Bartolomeo
309b703e47 C++: Models for side-effect-free functions
This commit adds a new model interface that describes the known side effects (or lack thereof) of a library function. Does it read memory, does it write memory, and do any of its parameters escape? Initially, we have models for just two Standard Library functions: `std::move` and `std::forward`, which neither read nor write memory, and do not escape their parameter.

IR construction has been updated to insert the correct side effect instruction (or no side effect instruction) based on the model.
2018-11-30 12:15:23 -08:00
Dave Bartolomeo
af443569d9 C++: Fix handling of accesses to escaped variables in Aliased SSA
This fixes a subtle bug in the construction of aliased SSA. `getResultMemoryAccess` was failing to return a `MemoryAccess` for a store to a variable whose address escaped. This is because no `VirtualIRVariable` was being created for such variables. The code was assuming that any access to such a variable would be via `UnknownMemoryAccess`. The result is that accesses to such variables were not being modeled in SSA at all.

Instead, the way to handle this is to have a `VariableMemoryAccess` even when the variable being accessed has escaped, and to have `VariableMemoryAccess::getVirtualVariable()` return the `UnknownVirtualVariable` for escaped variables. In the future, this will also let us be less conservative about inserting `Chi` nodes, because we'll be able to determine that there's an exact overlap between two accesses to the same escaped variable in some cases.
2018-11-30 12:15:19 -08:00
Dave Bartolomeo
ae8f18c0b5 C++: Treat all Convert instructions as dataflow
The AST dataflow library essentially ignores conversions, which is probably the right behavior. Converting an `int` to a `long` preserves the value, even if the bit pattern might be different. It's arguable whether narrowing conversions should be treated as dataflow, but we'll do so for now. We can revisit that if we see it cause problems.
2018-11-30 12:15:15 -08:00
Dave Bartolomeo
58f7596519 C++: IR-based dataflow 2018-11-30 12:15:11 -08:00
Kevin Backhouse
939db5a7cd Merge pull request #583 from jbj/bbStrictlyDominates-nomagic
C++: pragma[nomagic] on bbStrictlyDominates
2018-11-30 15:12:24 +00:00
Jonas Jensen
60076cb734 Merge pull request #532 from geoffw0/query-tags-3
CPP: Query Tags 3 (JPL_C queries)
2018-11-30 15:45:01 +01:00
Jonas Jensen
148c79a0e6 C++: Deprecate RecursionPrevention 2018-11-30 15:41:43 +01:00
Jonas Jensen
4712a8f913 C++: pragma[nomagic] on bbStrictlyPostDominates
This predicate was recently added and is likely to get the same problems
as `bbStrictlyDominates` with magic.
2018-11-30 11:37:18 +01:00
Jonas Jensen
ace8fa88f2 C++: pragma[nomagic] on bbStrictlyDominates
I noticed that queries using the data flow library spent significant
time in `#Dominance::bbIDominates#fbPlus`, which is the body of the
`bbStrictlyDominates` predicate. That predicate took 28 seconds to
compute on Wireshark.

The `b` in the predicate name means that magic was applied, and the
application of magic meant that it could not be evaluated with the
built-in `fastTC` HOP but became an explicit recursion instead. Applying
`pragma[nomagic]` to this predicate means that we will always get it
evaluated with `fastTC`, and that takes less than a second in my test
case.
2018-11-30 11:36:11 +01:00
Geoffrey White
453529e3bf Merge pull request #575 from jbj/UnsafeCreateProcessCall-nullValue
C++: Avoid using nullValue predicate (rc/1.19)
2018-11-30 09:54:17 +00:00
Jonas Jensen
9babb4366b Merge remote-tracking branch 'upstream/master' into mergeback-20181130 2018-11-30 10:13:33 +01:00
Jonas Jensen
dd3791490a Merge pull request #580 from geoffw0/av-79-perf
CPP: Fix performance issue with AV Rule 79.ql.
2018-11-30 08:39:38 +01:00
Jonas Jensen
b98452ddb1 Merge pull request #474 from rdmarsh2/rdmarsh/cpp/call-side-effect
C++: Initital aliased SSA with Chi nodes and function side effects
2018-11-29 18:31:29 +01:00
Geoffrey White
4744cece7b Merge pull request #576 from jbj/bbEntryReachesLocally-perf
C++: Fix performance of bbEntryReachesLocally (1.19)
2018-11-29 17:12:47 +00:00
Geoffrey White
e09ce77678 CPP: Fix performance issue with AV Rule 79.ql. 2018-11-29 15:16:01 +00:00
Mark Shannon
11ca7b74a3 Merge pull request #572 from geoffw0/deprecate-cpython
CPP: Delete CPython queries
2018-11-29 14:50:06 +00:00
Jonas Jensen
90ad5cfac5 Merge pull request #569 from geoffw0/deprecate-pointsto-debug
CPP: Deprecate the PointsTo debug queries.
2018-11-29 15:28:07 +01:00
Jonas Jensen
62d478eab3 C++: Fix performance of bbEntryReachesLocally
This predicate was fast with the queries and engine from 1.18. With the
queries from `master` it got a bad join order in the
`UninitializedLocal.ql` query, which made it take 2m34s on Wireshark.
This commit decomposes `bbEntryReachesLocally` into two predicates that
together take only 4s.
2018-11-29 15:11:32 +01:00
Jonas Jensen
8654ebcbbd C++: Avoid using nullValue predicate
The `nullValue` predicate performs a slow custom data-flow analysis to
find possible null values. It's so slow that it timed out after 1200s on
Wireshark.

In `UnsafeCreateProcessCall.ql`, the values found with `nullValue` were
used as sources in another data-flow analysis. By using the `NullValue`
class as sink instead of `nullValue`, we avoid the slow-down of doing
data flow twice. The `NullValue` class is essentially the base case of
`nullValue`. Confusing names, yes.
2018-11-29 13:33:45 +01:00
Jonas Jensen
d991fa84b1 Merge pull request #552 from geoffw0/move-security-tests-add
CPP: Add the Semmle security tests.
2018-11-29 10:49:20 +01:00
Geoffrey White
9d95291124 CPP: Delete the CPython queries and libraries. 2018-11-29 09:29:46 +00:00
Geoffrey White
909ff428ac CPP: Deprecate the CPython queries. 2018-11-29 09:28:29 +00:00
Dave Bartolomeo
40864f9ebb C++: Fix GVN test expectation 2018-11-28 14:07:23 -08:00
semmle-qlci
d31c9950f9 Merge pull request #566 from ian-semmle/defuse_test
Approved by dave-bartolomeo
2018-11-28 20:48:14 +00:00
Geoffrey White
d261f1b6d2 CPP: Deprecate the PointsTo tests. 2018-11-28 20:23:33 +00:00
Dave Bartolomeo
d7938362dd C++: Rename Chi IPA types to match classes 2018-11-28 10:33:04 -08:00
Geoffrey White
1232694340 CPP: Add external/jpl tags. 2018-11-28 18:18:28 +00:00
Ian Lynagh
6cb6b1c07d C++: Tweak the defuse test
It looks like this is what it was originally intended to do.
2018-11-28 17:11:17 +00:00
Geoffrey White
0eb0bf988e CPP: Fix for virtual method calls. 2018-11-28 14:19:24 +00:00
Dave Bartolomeo
5d997c7135 C++: Big QLDoc comment for ChiInstruction 2018-11-27 17:09:26 -08:00
Dave Bartolomeo
53cd5e9994 C++: Fix bug introduced by earlier commit 2018-11-27 14:57:58 -08:00
Dave Bartolomeo
7e6e6f00c1 C++: Fix IR for designated array initializers 2018-11-27 14:57:23 -08:00
Dave Bartolomeo
0a20f9ffbf C++: Print field names and element indices for aggregate literals in PrintAST 2018-11-27 13:26:18 -08:00
Dave Bartolomeo
90b79eb5f3 C++: Accept GVN test expectations with Chi nodes 2018-11-27 12:56:23 -08:00
Geoffrey White
7107cec503 CPP: Add test cases. 2018-11-27 17:20:14 +00:00
Jonas Jensen
c403bb1cad Merge pull request #541 from kevinbackhouse/CppPostDominators
Add post-dominators
2018-11-27 08:23:43 +01:00
Dave Bartolomeo
689002a22e C++: Fix handling of Chi instructions in sign analysis 2018-11-26 16:46:39 -08:00
Robert Marsh
f4ce7b9648 C++: respond to further PR review comments 2018-11-26 16:16:46 -08:00
Robert Marsh
7ef0d5e98d C++: respond to technical nits 2018-11-26 15:47:47 -08:00
Dave Bartolomeo
2b9afe95e8 C++: Accept test output after rebase 2018-11-26 12:08:19 -08:00
Robert Marsh
799eb06eea C++: add AliasedDefinition for aliased SSA 2018-11-26 12:08:19 -08:00
Robert Marsh
3ee033d96e C++: IR sanity fixes for Chi nodes 2018-11-26 12:08:19 -08:00
Robert Marsh
b401cd97f2 C++: use UnmodeledDefinition in UnmodeledUse 2018-11-26 12:08:19 -08:00
Robert Marsh
927f935e62 C++: hook ChiInstructions into the operand graph 2018-11-26 12:08:19 -08:00
Robert Marsh
a33b59103a C++: insert Chi nodes in the IR successor relation
This commit adds Chi nodes to the successor relation and accounts for
them in the CFG, but does not add them to the SSA data graph. Chi nodes
are inserted for partial writes to any VirtualVariable, regardless of
whether the partial write reaches any uses.
2018-11-26 12:08:18 -08:00
Dave Bartolomeo
1fb36ff7e7 C++: Add conservative side effects for function calls 2018-11-26 12:08:18 -08:00