Skip to content

Commit ffa55b4

Browse files
committed
C++: Disable special casing of Phi operands in alias analysis. Instead, we simply add flow through them.
1 parent ef85329 commit ffa55b4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysis.qll

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ private predicate operandEscapesDomain(Operand operand) {
106106
not isArgumentForParameter(_, operand, _) and
107107
not isOnlyEscapesViaReturnArgument(operand) and
108108
not operand.getUse() instanceof ReturnValueInstruction and
109-
not operand.getUse() instanceof ReturnIndirectionInstruction and
110-
not operand instanceof PhiInputOperand
109+
not operand.getUse() instanceof ReturnIndirectionInstruction
111110
}
112111

113112
/**
@@ -191,6 +190,11 @@ private predicate operandIsPropagated(Operand operand, IntValue bitOffset, Instr
191190
// A copy propagates the source value.
192191
operand = instr.(CopyInstruction).getSourceValueOperand() and bitOffset = 0
193192
)
193+
or
194+
operand = instr.(PhiInstruction).getAnInputOperand() and
195+
// Using `unknown` ensures termination since we cannot keep incrementing a bit offset
196+
// through the back edge of a loop (or through recursion).
197+
bitOffset = Ints::unknown()
194198
}
195199

196200
private predicate operandEscapesNonReturn(Operand operand) {
@@ -212,9 +216,6 @@ private predicate operandEscapesNonReturn(Operand operand) {
212216
or
213217
isOnlyEscapesViaReturnArgument(operand) and resultEscapesNonReturn(operand.getUse())
214218
or
215-
operand instanceof PhiInputOperand and
216-
resultEscapesNonReturn(operand.getUse())
217-
or
218219
operandEscapesDomain(operand)
219220
}
220221

@@ -236,9 +237,6 @@ private predicate operandMayReachReturn(Operand operand) {
236237
operand.getUse() instanceof ReturnValueInstruction
237238
or
238239
isOnlyEscapesViaReturnArgument(operand) and resultMayReachReturn(operand.getUse())
239-
or
240-
operand instanceof PhiInputOperand and
241-
resultMayReachReturn(operand.getUse())
242240
}
243241

244242
private predicate operandReturned(Operand operand, IntValue bitOffset) {

0 commit comments

Comments
 (0)