Skip to content

Commit 6f3a2c4

Browse files
committed
C++: Fill in skeleton for indirect instruction/operand barrier nodes.
1 parent 4e3b27e commit 6f3a2c4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,11 +2495,35 @@ module InstructionBarrierGuard<instructionGuardChecksSig/3 instructionGuardCheck
24952495
)
24962496
}
24972497

2498+
bindingset[value, n]
2499+
pragma[inline_late]
2500+
private predicate indirectOperandHasValueNumber(ValueNumber value, int indirectionIndex, Node n) {
2501+
exists(Operand use |
2502+
use = value.getAnInstruction().getAUse() and
2503+
n.asIndirectOperand(indirectionIndex) = use
2504+
)
2505+
}
2506+
24982507
/**
24992508
* Gets an indirect node with indirection index `indirectionIndex` that is
25002509
* safely guarded by the given guard check.
25012510
*/
2502-
Node getAnIndirectBarrierNode(int indirectionIndex) { none() }
2511+
Node getAnIndirectBarrierNode(int indirectionIndex) {
2512+
exists(IRGuardCondition g, ValueNumber value, boolean edge |
2513+
instructionGuardChecks(g, pragma[only_bind_into](value.getAnInstruction()), edge) and
2514+
indirectOperandHasValueNumber(value, indirectionIndex, result) and
2515+
controls(g, result, edge)
2516+
)
2517+
or
2518+
exists(
2519+
IRGuardCondition g, boolean branch, Ssa::DefinitionExt def, IRBlock input, Ssa::PhiNode phi
2520+
|
2521+
instructionGuardChecks(g, def.getARead().asIndirectOperand(indirectionIndex).getDef(), branch) and
2522+
guardControlsPhiInput(g, branch, def, pragma[only_bind_into](input),
2523+
pragma[only_bind_into](phi)) and
2524+
result = TSsaPhiInputNode(phi, input)
2525+
)
2526+
}
25032527
}
25042528

25052529
/**

0 commit comments

Comments
 (0)