From ace8fa88f2d353a583c6108af152de10bebbbc0d Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Fri, 30 Nov 2018 08:22:27 +0100 Subject: [PATCH 1/2] 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. --- cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll b/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll index 463778fbbf2..792aa6a84da 100644 --- a/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll +++ b/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll @@ -126,6 +126,7 @@ predicate bbIPostDominates(BasicBlock pDom, BasicBlock node) = idominance(bb_exi * Holds if `dominator` is a strict dominator of `node` in the control-flow * graph of basic blocks. Being strict means that `dominator != node`. */ +pragma[nomagic] // magic prevents fastTC predicate bbStrictlyDominates(BasicBlock dominator, BasicBlock node) { bbIDominates+(dominator, node) } From 4712a8f9134b3ab8dc4325f1701ffc9f6ecd3f74 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Fri, 30 Nov 2018 11:37:18 +0100 Subject: [PATCH 2/2] C++: pragma[nomagic] on bbStrictlyPostDominates This predicate was recently added and is likely to get the same problems as `bbStrictlyDominates` with magic. --- cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll b/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll index 792aa6a84da..b05de61beb7 100644 --- a/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll +++ b/cpp/ql/src/semmle/code/cpp/controlflow/Dominance.qll @@ -135,6 +135,7 @@ predicate bbStrictlyDominates(BasicBlock dominator, BasicBlock node) { * Holds if `postDominator` is a strict post-dominator of `node` in the control-flow * graph of basic blocks. Being strict means that `postDominator != node`. */ +pragma[nomagic] // magic prevents fastTC predicate bbStrictlyPostDominates(BasicBlock postDominator, BasicBlock node) { bbIPostDominates+(postDominator, node) }