Skip to content

Commit 91b29ee

Browse files
committed
C++: Don't use GVN as an SSAVariable in range analysis.
1 parent a04830b commit 91b29ee

File tree

1 file changed

+4
-38
lines changed

1 file changed

+4
-38
lines changed

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/SemanticExprSpecific.qll

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,7 @@ module SemanticExprConfig {
132132

133133
newtype TSsaVariable =
134134
TSsaInstruction(IR::Instruction instr) { instr.hasMemoryResult() } or
135-
TSsaOperand(IR::Operand op) { op.isDefinitionInexact() } or
136-
TSsaPointerArithmeticGuard(ValueNumber instr) {
137-
exists(Guard g, IR::Operand use |
138-
use = instr.getAUse() and use.getIRType() instanceof IR::IRAddressType
139-
|
140-
g.comparesLt(use, _, _, _, _) or
141-
g.comparesLt(_, use, _, _, _) or
142-
g.comparesEq(use, _, _, _, _) or
143-
g.comparesEq(_, use, _, _, _)
144-
)
145-
}
135+
TSsaOperand(IR::Operand op) { op.isDefinitionInexact() }
146136

147137
class SsaVariable extends TSsaVariable {
148138
string toString() { none() }
@@ -151,8 +141,6 @@ module SemanticExprConfig {
151141

152142
IR::Instruction asInstruction() { none() }
153143

154-
ValueNumber asPointerArithGuard() { none() }
155-
156144
IR::Operand asOperand() { none() }
157145
}
158146

@@ -168,18 +156,6 @@ module SemanticExprConfig {
168156
final override IR::Instruction asInstruction() { result = instr }
169157
}
170158

171-
class SsaPointerArithmeticGuard extends SsaVariable, TSsaPointerArithmeticGuard {
172-
ValueNumber vn;
173-
174-
SsaPointerArithmeticGuard() { this = TSsaPointerArithmeticGuard(vn) }
175-
176-
final override string toString() { result = vn.toString() }
177-
178-
final override Location getLocation() { result = vn.getLocation() }
179-
180-
final override ValueNumber asPointerArithGuard() { result = vn }
181-
}
182-
183159
class SsaOperand extends SsaVariable, TSsaOperand {
184160
IR::Operand op;
185161

@@ -212,11 +188,7 @@ module SemanticExprConfig {
212188
)
213189
}
214190

215-
Expr getAUse(SsaVariable v) {
216-
result.(IR::LoadInstruction).getSourceValue() = v.asInstruction()
217-
or
218-
result = v.asPointerArithGuard().getAnInstruction()
219-
}
191+
Expr getAUse(SsaVariable v) { result.(IR::LoadInstruction).getSourceValue() = v.asInstruction() }
220192

221193
SemType getSsaVariableType(SsaVariable v) {
222194
result = getSemanticType(v.asInstruction().getResultIRType())
@@ -255,10 +227,7 @@ module SemanticExprConfig {
255227
final override Location getLocation() { result = block.getLocation() }
256228

257229
final override predicate hasRead(SsaVariable v) {
258-
exists(IR::Operand operand |
259-
operand.getDef() = v.asInstruction() or
260-
operand.getDef() = v.asPointerArithGuard().getAnInstruction()
261-
|
230+
exists(IR::Operand operand | operand.getDef() = v.asInstruction() |
262231
not operand instanceof IR::PhiInputOperand and
263232
operand.getUse().getBlock() = block
264233
)
@@ -276,10 +245,7 @@ module SemanticExprConfig {
276245
final override Location getLocation() { result = succ.getLocation() }
277246

278247
final override predicate hasRead(SsaVariable v) {
279-
exists(IR::PhiInputOperand operand |
280-
operand.getDef() = v.asInstruction() or
281-
operand.getDef() = v.asPointerArithGuard().getAnInstruction()
282-
|
248+
exists(IR::PhiInputOperand operand | operand.getDef() = v.asInstruction() |
283249
operand.getPredecessorBlock() = pred and
284250
operand.getUse().getBlock() = succ
285251
)

0 commit comments

Comments
 (0)