Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66e7c26

Browse files
committed
C++: Replace FastTC with iteration in ignoreExpr
Before, `ignoreExprAndDescendants` and its related predicates had this timing on Wireshark. #TranslatedElement::getRealParent#ffPlus#swapped ......... 25.7s TranslatedElement::ignoreExprAndDescendants#f ............ 16.9s TranslatedElement::getRealParent#ff ...................... 7.2s TranslatedElement::ignoreExpr#f .......................... 4.8s TranslatedElement::ignoreExpr#f#antijoin_rhs ............. 3.2s TranslatedElement::getRealParent#ff_10#higher_order_body . 2.2s After, it looks like this TranslatedElement::ignoreExprAndDescendants#f ............ 23.4s (executed 9 times) TranslatedElement::getRealParent#ff ...................... 6.3s TranslatedElement::ignoreExpr#f#antijoin_rhs ............. 4.8s TranslatedElement::ignoreExpr#f .......................... 3.7s TranslatedElement::getRealParent#ff_10#join_rhs .......... 2.5s project#TranslatedElement::getRealParent#ff .............. 1.3s
1 parent 6243c72 commit 66e7c26

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ private Element getRealParent(Expr expr) {
3636
predicate isIRConstant(Expr expr) { exists(expr.getValue()) }
3737

3838
/**
39-
* Holds if `expr` and all of its descendants should be ignored for the purposes
40-
* of IR generation due to some property of `expr` itself. Unlike
41-
* `ignoreExpr()`, this predicate does not ignore an expression solely because
42-
* it is a descendant of an ignored element.
39+
* Holds if `expr` should be ignored for the purposes of IR generation due to
40+
* some property of `expr` or one of its ancestors.
4341
*/
4442
private predicate ignoreExprAndDescendants(Expr expr) {
4543
// Ignore parentless expressions
@@ -59,7 +57,8 @@ private predicate ignoreExprAndDescendants(Expr expr) {
5957
// REVIEW: Ignore initializers for `NewArrayExpr` until we determine how to
6058
// represent them.
6159
newExpr.getInitializer().getFullyConverted() = expr
62-
)
60+
) or
61+
ignoreExprAndDescendants(getRealParent(expr)) // recursive case
6362
}
6463

6564
/**
@@ -80,7 +79,7 @@ private predicate ignoreExprOnly(Expr expr) {
8079
*/
8180
private predicate ignoreExpr(Expr expr) {
8281
ignoreExprOnly(expr) or
83-
ignoreExprAndDescendants(getRealParent*(expr))
82+
ignoreExprAndDescendants(expr)
8483
}
8584

8685
/**

0 commit comments

Comments
 (0)