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

Skip to content

Commit 2f0c772

Browse files
author
Robert Marsh
authored
Merge pull request #10818 from github/mathiasvp/fix-join-in-ssa-internals
C++: Fix join in `SsaInternals`
2 parents 5cd6daf + 134cc62 commit 2f0c772

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,29 @@ predicate ssaFlow(Node nodeFrom, Node nodeTo) {
371371
)
372372
}
373373

374+
/**
375+
* Holds if `use` is a use of `sv` and is a next adjacent use of `phi` in
376+
* index `i1` in basic block `bb1`.
377+
*
378+
* This predicate exists to prevent an early join of `adjacentDefRead` with `definesAt`.
379+
*/
380+
pragma[nomagic]
381+
private predicate fromPhiNodeToUse(PhiNode phi, SourceVariable sv, IRBlock bb1, int i1, UseOrPhi use) {
382+
exists(IRBlock bb2, int i2 |
383+
use.asDefOrUse().hasIndexInBlock(bb2, i2, sv) and
384+
adjacentDefRead(pragma[only_bind_into](phi), pragma[only_bind_into](bb1),
385+
pragma[only_bind_into](i1), pragma[only_bind_into](bb2), pragma[only_bind_into](i2))
386+
)
387+
}
388+
374389
/** Holds if `nodeTo` receives flow from the phi node `nodeFrom`. */
375390
predicate fromPhiNode(SsaPhiNode nodeFrom, Node nodeTo) {
376391
exists(PhiNode phi, SourceVariable sv, IRBlock bb1, int i1, UseOrPhi use |
377392
phi = nodeFrom.getPhiNode() and
378393
phi.definesAt(sv, bb1, i1) and
379394
useToNode(use, nodeTo)
380395
|
381-
exists(IRBlock bb2, int i2 |
382-
use.asDefOrUse().hasIndexInBlock(bb2, i2, sv) and
383-
adjacentDefRead(phi, bb1, i1, bb2, i2)
384-
)
396+
fromPhiNodeToUse(phi, sv, bb1, i1, use)
385397
or
386398
exists(PhiNode phiTo |
387399
lastRefRedef(phi, _, _, phiTo) and

0 commit comments

Comments
 (0)