Skip to content

Commit 523fc9c

Browse files
committed
C++ IR: make isInCycle fast
Without this `pragma[noopt]`, `isInCycle` gets compiled into RA that unpacks every tuple of the fast TC: 0 ~0% {2} r1 = SELECT #Operand::getNonPhiOperandDef#3#ffPlus ON FIELDS #Operand::getNonPhiOperandDef#3#ffPlus.<0>=#Operand::getNonPhiOperandDef#3#ffPlus.<1> 0 ~0% {1} r2 = SCAN r1 OUTPUT FIELDS {r1.<0>} return r2 With this change, it just becomes one lookup in the fast TC data structure per instruction.
1 parent 39854a3 commit 523fc9c

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ private Instruction getNonPhiOperandDef(Instruction instr) {
3535
* analyses that assume a cycle-free graph of non-phi operands. Therefore it's
3636
* better to remove these operands than to leave cycles in the operand graph.
3737
*/
38+
pragma[noopt]
3839
private predicate isInCycle(Instruction instr) {
40+
instr instanceof Instruction and
3941
getNonPhiOperandDef+(instr) = instr
4042
}
4143

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Operand.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ private Instruction getNonPhiOperandDef(Instruction instr) {
3535
* analyses that assume a cycle-free graph of non-phi operands. Therefore it's
3636
* better to remove these operands than to leave cycles in the operand graph.
3737
*/
38+
pragma[noopt]
3839
private predicate isInCycle(Instruction instr) {
40+
instr instanceof Instruction and
3941
getNonPhiOperandDef+(instr) = instr
4042
}
4143

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ private Instruction getNonPhiOperandDef(Instruction instr) {
3535
* analyses that assume a cycle-free graph of non-phi operands. Therefore it's
3636
* better to remove these operands than to leave cycles in the operand graph.
3737
*/
38+
pragma[noopt]
3839
private predicate isInCycle(Instruction instr) {
40+
instr instanceof Instruction and
3941
getNonPhiOperandDef+(instr) = instr
4042
}
4143

0 commit comments

Comments
 (0)