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

Skip to content

Commit 9b69961

Browse files
committed
Data flow: Improve performance of flowFwdStore()
1 parent f30a42c commit 9b69961

19 files changed

Lines changed: 361 additions & 171 deletions

File tree

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ private predicate flowFwdStore(
18381838
) {
18391839
exists(NodeExt mid, AccessPathFront apf0, boolean through |
18401840
flowFwd(mid, fromArg, apf0, ap0, config) and
1841-
flowFwdStoreAux(mid, f, node, through, apf0, apf, config)
1841+
flowFwdStore1(mid, f, node, through, apf0, apf, config)
18421842
|
18431843
through = false or ap0.isValidForFlowThrough()
18441844
)
@@ -1853,12 +1853,20 @@ private predicate flowFwdStore(
18531853
)
18541854
}
18551855

1856-
private predicate flowFwdStoreAux(
1856+
pragma[noinline]
1857+
private predicate flowFwdStore0(
1858+
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, Configuration config
1859+
) {
1860+
storeExt(mid, f, node, through) and
1861+
consCand(f, apf0, config)
1862+
}
1863+
1864+
pragma[noinline]
1865+
private predicate flowFwdStore1(
18571866
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, AccessPathFront apf,
18581867
Configuration config
18591868
) {
1860-
storeExt(mid, f, node, through) and
1861-
consCand(f, apf0, config) and
1869+
flowFwdStore0(mid, f, node, through, apf0, config) and
18621870
apf.headUsesContent(f) and
18631871
flowCand(node, _, apf, unbind(config))
18641872
}
@@ -1958,7 +1966,7 @@ private predicate flow0(NodeExt node, boolean toReturn, AccessPath ap, Configura
19581966
)
19591967
or
19601968
exists(NodeExt mid, AccessPath ap0 |
1961-
readFwd(node, _, mid, ap, ap0, config) and
1969+
readFwd(node, mid, ap, ap0, config) and
19621970
flow(mid, toReturn, ap0, config)
19631971
)
19641972
or
@@ -1991,11 +1999,13 @@ private predicate flowTaintStore(
19911999

19922000
pragma[nomagic]
19932001
private predicate readFwd(
1994-
NodeExt node1, Content f, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
2002+
NodeExt node1, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
19952003
) {
1996-
readExt(node1, f, node2, _) and
1997-
flowFwdRead(node2, f, ap, _, config) and
1998-
ap0 = pop(f, ap)
2004+
exists(Content f |
2005+
readExt(node1, f, node2, _) and
2006+
flowFwdRead(node2, f, ap, _, config) and
2007+
ap0 = pop(f, ap)
2008+
)
19992009
}
20002010

20012011
bindingset[conf, result]

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ private predicate flowFwdStore(
18381838
) {
18391839
exists(NodeExt mid, AccessPathFront apf0, boolean through |
18401840
flowFwd(mid, fromArg, apf0, ap0, config) and
1841-
flowFwdStoreAux(mid, f, node, through, apf0, apf, config)
1841+
flowFwdStore1(mid, f, node, through, apf0, apf, config)
18421842
|
18431843
through = false or ap0.isValidForFlowThrough()
18441844
)
@@ -1853,12 +1853,20 @@ private predicate flowFwdStore(
18531853
)
18541854
}
18551855

1856-
private predicate flowFwdStoreAux(
1856+
pragma[noinline]
1857+
private predicate flowFwdStore0(
1858+
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, Configuration config
1859+
) {
1860+
storeExt(mid, f, node, through) and
1861+
consCand(f, apf0, config)
1862+
}
1863+
1864+
pragma[noinline]
1865+
private predicate flowFwdStore1(
18571866
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, AccessPathFront apf,
18581867
Configuration config
18591868
) {
1860-
storeExt(mid, f, node, through) and
1861-
consCand(f, apf0, config) and
1869+
flowFwdStore0(mid, f, node, through, apf0, config) and
18621870
apf.headUsesContent(f) and
18631871
flowCand(node, _, apf, unbind(config))
18641872
}
@@ -1958,7 +1966,7 @@ private predicate flow0(NodeExt node, boolean toReturn, AccessPath ap, Configura
19581966
)
19591967
or
19601968
exists(NodeExt mid, AccessPath ap0 |
1961-
readFwd(node, _, mid, ap, ap0, config) and
1969+
readFwd(node, mid, ap, ap0, config) and
19621970
flow(mid, toReturn, ap0, config)
19631971
)
19641972
or
@@ -1991,11 +1999,13 @@ private predicate flowTaintStore(
19911999

19922000
pragma[nomagic]
19932001
private predicate readFwd(
1994-
NodeExt node1, Content f, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
2002+
NodeExt node1, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
19952003
) {
1996-
readExt(node1, f, node2, _) and
1997-
flowFwdRead(node2, f, ap, _, config) and
1998-
ap0 = pop(f, ap)
2004+
exists(Content f |
2005+
readExt(node1, f, node2, _) and
2006+
flowFwdRead(node2, f, ap, _, config) and
2007+
ap0 = pop(f, ap)
2008+
)
19992009
}
20002010

20012011
bindingset[conf, result]

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ private predicate flowFwdStore(
18381838
) {
18391839
exists(NodeExt mid, AccessPathFront apf0, boolean through |
18401840
flowFwd(mid, fromArg, apf0, ap0, config) and
1841-
flowFwdStoreAux(mid, f, node, through, apf0, apf, config)
1841+
flowFwdStore1(mid, f, node, through, apf0, apf, config)
18421842
|
18431843
through = false or ap0.isValidForFlowThrough()
18441844
)
@@ -1853,12 +1853,20 @@ private predicate flowFwdStore(
18531853
)
18541854
}
18551855

1856-
private predicate flowFwdStoreAux(
1856+
pragma[noinline]
1857+
private predicate flowFwdStore0(
1858+
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, Configuration config
1859+
) {
1860+
storeExt(mid, f, node, through) and
1861+
consCand(f, apf0, config)
1862+
}
1863+
1864+
pragma[noinline]
1865+
private predicate flowFwdStore1(
18571866
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, AccessPathFront apf,
18581867
Configuration config
18591868
) {
1860-
storeExt(mid, f, node, through) and
1861-
consCand(f, apf0, config) and
1869+
flowFwdStore0(mid, f, node, through, apf0, config) and
18621870
apf.headUsesContent(f) and
18631871
flowCand(node, _, apf, unbind(config))
18641872
}
@@ -1958,7 +1966,7 @@ private predicate flow0(NodeExt node, boolean toReturn, AccessPath ap, Configura
19581966
)
19591967
or
19601968
exists(NodeExt mid, AccessPath ap0 |
1961-
readFwd(node, _, mid, ap, ap0, config) and
1969+
readFwd(node, mid, ap, ap0, config) and
19621970
flow(mid, toReturn, ap0, config)
19631971
)
19641972
or
@@ -1991,11 +1999,13 @@ private predicate flowTaintStore(
19911999

19922000
pragma[nomagic]
19932001
private predicate readFwd(
1994-
NodeExt node1, Content f, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
2002+
NodeExt node1, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
19952003
) {
1996-
readExt(node1, f, node2, _) and
1997-
flowFwdRead(node2, f, ap, _, config) and
1998-
ap0 = pop(f, ap)
2004+
exists(Content f |
2005+
readExt(node1, f, node2, _) and
2006+
flowFwdRead(node2, f, ap, _, config) and
2007+
ap0 = pop(f, ap)
2008+
)
19992009
}
20002010

20012011
bindingset[conf, result]

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ private predicate flowFwdStore(
18381838
) {
18391839
exists(NodeExt mid, AccessPathFront apf0, boolean through |
18401840
flowFwd(mid, fromArg, apf0, ap0, config) and
1841-
flowFwdStoreAux(mid, f, node, through, apf0, apf, config)
1841+
flowFwdStore1(mid, f, node, through, apf0, apf, config)
18421842
|
18431843
through = false or ap0.isValidForFlowThrough()
18441844
)
@@ -1853,12 +1853,20 @@ private predicate flowFwdStore(
18531853
)
18541854
}
18551855

1856-
private predicate flowFwdStoreAux(
1856+
pragma[noinline]
1857+
private predicate flowFwdStore0(
1858+
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, Configuration config
1859+
) {
1860+
storeExt(mid, f, node, through) and
1861+
consCand(f, apf0, config)
1862+
}
1863+
1864+
pragma[noinline]
1865+
private predicate flowFwdStore1(
18571866
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, AccessPathFront apf,
18581867
Configuration config
18591868
) {
1860-
storeExt(mid, f, node, through) and
1861-
consCand(f, apf0, config) and
1869+
flowFwdStore0(mid, f, node, through, apf0, config) and
18621870
apf.headUsesContent(f) and
18631871
flowCand(node, _, apf, unbind(config))
18641872
}
@@ -1958,7 +1966,7 @@ private predicate flow0(NodeExt node, boolean toReturn, AccessPath ap, Configura
19581966
)
19591967
or
19601968
exists(NodeExt mid, AccessPath ap0 |
1961-
readFwd(node, _, mid, ap, ap0, config) and
1969+
readFwd(node, mid, ap, ap0, config) and
19621970
flow(mid, toReturn, ap0, config)
19631971
)
19641972
or
@@ -1991,11 +1999,13 @@ private predicate flowTaintStore(
19911999

19922000
pragma[nomagic]
19932001
private predicate readFwd(
1994-
NodeExt node1, Content f, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
2002+
NodeExt node1, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
19952003
) {
1996-
readExt(node1, f, node2, _) and
1997-
flowFwdRead(node2, f, ap, _, config) and
1998-
ap0 = pop(f, ap)
2004+
exists(Content f |
2005+
readExt(node1, f, node2, _) and
2006+
flowFwdRead(node2, f, ap, _, config) and
2007+
ap0 = pop(f, ap)
2008+
)
19992009
}
20002010

20012011
bindingset[conf, result]

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplLocal.qll

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ private predicate flowFwdStore(
18381838
) {
18391839
exists(NodeExt mid, AccessPathFront apf0, boolean through |
18401840
flowFwd(mid, fromArg, apf0, ap0, config) and
1841-
flowFwdStoreAux(mid, f, node, through, apf0, apf, config)
1841+
flowFwdStore1(mid, f, node, through, apf0, apf, config)
18421842
|
18431843
through = false or ap0.isValidForFlowThrough()
18441844
)
@@ -1853,12 +1853,20 @@ private predicate flowFwdStore(
18531853
)
18541854
}
18551855

1856-
private predicate flowFwdStoreAux(
1856+
pragma[noinline]
1857+
private predicate flowFwdStore0(
1858+
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, Configuration config
1859+
) {
1860+
storeExt(mid, f, node, through) and
1861+
consCand(f, apf0, config)
1862+
}
1863+
1864+
pragma[noinline]
1865+
private predicate flowFwdStore1(
18571866
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, AccessPathFront apf,
18581867
Configuration config
18591868
) {
1860-
storeExt(mid, f, node, through) and
1861-
consCand(f, apf0, config) and
1869+
flowFwdStore0(mid, f, node, through, apf0, config) and
18621870
apf.headUsesContent(f) and
18631871
flowCand(node, _, apf, unbind(config))
18641872
}
@@ -1958,7 +1966,7 @@ private predicate flow0(NodeExt node, boolean toReturn, AccessPath ap, Configura
19581966
)
19591967
or
19601968
exists(NodeExt mid, AccessPath ap0 |
1961-
readFwd(node, _, mid, ap, ap0, config) and
1969+
readFwd(node, mid, ap, ap0, config) and
19621970
flow(mid, toReturn, ap0, config)
19631971
)
19641972
or
@@ -1991,11 +1999,13 @@ private predicate flowTaintStore(
19911999

19922000
pragma[nomagic]
19932001
private predicate readFwd(
1994-
NodeExt node1, Content f, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
2002+
NodeExt node1, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
19952003
) {
1996-
readExt(node1, f, node2, _) and
1997-
flowFwdRead(node2, f, ap, _, config) and
1998-
ap0 = pop(f, ap)
2004+
exists(Content f |
2005+
readExt(node1, f, node2, _) and
2006+
flowFwdRead(node2, f, ap, _, config) and
2007+
ap0 = pop(f, ap)
2008+
)
19992009
}
20002010

20012011
bindingset[conf, result]

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ private predicate flowFwdStore(
18381838
) {
18391839
exists(NodeExt mid, AccessPathFront apf0, boolean through |
18401840
flowFwd(mid, fromArg, apf0, ap0, config) and
1841-
flowFwdStoreAux(mid, f, node, through, apf0, apf, config)
1841+
flowFwdStore1(mid, f, node, through, apf0, apf, config)
18421842
|
18431843
through = false or ap0.isValidForFlowThrough()
18441844
)
@@ -1853,12 +1853,20 @@ private predicate flowFwdStore(
18531853
)
18541854
}
18551855

1856-
private predicate flowFwdStoreAux(
1856+
pragma[noinline]
1857+
private predicate flowFwdStore0(
1858+
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, Configuration config
1859+
) {
1860+
storeExt(mid, f, node, through) and
1861+
consCand(f, apf0, config)
1862+
}
1863+
1864+
pragma[noinline]
1865+
private predicate flowFwdStore1(
18571866
NodeExt mid, Content f, NodeExt node, boolean through, AccessPathFront apf0, AccessPathFront apf,
18581867
Configuration config
18591868
) {
1860-
storeExt(mid, f, node, through) and
1861-
consCand(f, apf0, config) and
1869+
flowFwdStore0(mid, f, node, through, apf0, config) and
18621870
apf.headUsesContent(f) and
18631871
flowCand(node, _, apf, unbind(config))
18641872
}
@@ -1958,7 +1966,7 @@ private predicate flow0(NodeExt node, boolean toReturn, AccessPath ap, Configura
19581966
)
19591967
or
19601968
exists(NodeExt mid, AccessPath ap0 |
1961-
readFwd(node, _, mid, ap, ap0, config) and
1969+
readFwd(node, mid, ap, ap0, config) and
19621970
flow(mid, toReturn, ap0, config)
19631971
)
19641972
or
@@ -1991,11 +1999,13 @@ private predicate flowTaintStore(
19911999

19922000
pragma[nomagic]
19932001
private predicate readFwd(
1994-
NodeExt node1, Content f, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
2002+
NodeExt node1, NodeExt node2, AccessPath ap, AccessPath ap0, Configuration config
19952003
) {
1996-
readExt(node1, f, node2, _) and
1997-
flowFwdRead(node2, f, ap, _, config) and
1998-
ap0 = pop(f, ap)
2004+
exists(Content f |
2005+
readExt(node1, f, node2, _) and
2006+
flowFwdRead(node2, f, ap, _, config) and
2007+
ap0 = pop(f, ap)
2008+
)
19992009
}
20002010

20012011
bindingset[conf, result]

0 commit comments

Comments
 (0)