Skip to content

Commit 42c659b

Browse files
author
Dave Bartolomeo
committed
C++/C#: Remove UnmodeledDefinition instruction
1 parent 35868d4 commit 42c659b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3798
-4462
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/MemoryAccessKind.qll

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,3 @@ class ChiTotalMemoryAccess extends MemoryAccessKind, TChiTotalMemoryAccess {
9292
class ChiPartialMemoryAccess extends MemoryAccessKind, TChiPartialMemoryAccess {
9393
override string toString() { result = "chi(partial)" }
9494
}
95-
96-
/**
97-
* The operand accesses memory not modeled in SSA. Used only on the result of
98-
* `UnmodeledDefinition` and on the operands of `UnmodeledUse`.
99-
*/
100-
class UnmodeledMemoryAccess extends MemoryAccessKind, TUnmodeledMemoryAccess {
101-
override string toString() { result = "unmodeled" }
102-
}

cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ private newtype TOpcode =
6060
TThrowValue() or
6161
TReThrow() or
6262
TUnwind() or
63-
TUnmodeledDefinition() or
6463
TAliasedDefinition() or
6564
TInitializeNonLocal() or
6665
TAliasedUse() or
@@ -578,14 +577,6 @@ module Opcode {
578577
final override string toString() { result = "Unwind" }
579578
}
580579

581-
class UnmodeledDefinition extends Opcode, TUnmodeledDefinition {
582-
final override string toString() { result = "UnmodeledDefinition" }
583-
584-
final override MemoryAccessKind getWriteMemoryAccess() {
585-
result instanceof UnmodeledMemoryAccess
586-
}
587-
}
588-
589580
class AliasedDefinition extends Opcode, TAliasedDefinition {
590581
final override string toString() { result = "AliasedDefinition" }
591582

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ module InstructionConsistency {
149149
}
150150

151151
/**
152-
* Holds if a memory operand is connected to a definition with an unmodeled result, other than
153-
* `UnmodeledDefinition` itself.
152+
* Holds if a memory operand is connected to a definition with an unmodeled result.
154153
*/
155154
query predicate memoryOperandDefinitionIsUnmodeled(
156155
Instruction instr, string message, IRFunction func, string funcText
@@ -159,9 +158,8 @@ module InstructionConsistency {
159158
operand = instr.getAnOperand() and
160159
def = operand.getAnyDef() and
161160
not def.isResultModeled() and
162-
not def instanceof UnmodeledDefinitionInstruction and
163161
message =
164-
"Memory operand definition has unmodeled result, but is not the `UnmodeledDefinition` instruction in function '$@'" and
162+
"Memory operand definition has unmodeled result in function '$@'" and
165163
func = instr.getEnclosingIRFunction() and
166164
funcText = Language::getIdentityString(func.getFunction())
167165
)
@@ -257,7 +255,6 @@ module InstructionConsistency {
257255
Operand useOperand, string message, IRFunction func, string funcText
258256
) {
259257
exists(IRBlock useBlock, int useIndex, Instruction defInstr, IRBlock defBlock, int defIndex |
260-
not defInstr instanceof UnmodeledDefinitionInstruction and
261258
pointOfEvaluation(useOperand, useBlock, useIndex) and
262259
defInstr = useOperand.getAnyDef() and
263260
(
@@ -306,8 +303,6 @@ module InstructionConsistency {
306303
private predicate shouldBeConflated(Instruction instr) {
307304
isOnAliasedDefinitionChain(instr)
308305
or
309-
instr instanceof UnmodeledDefinitionInstruction
310-
or
311306
instr.getOpcode() instanceof Opcode::InitializeNonLocal
312307
}
313308

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class IRFunction extends TIRFunction {
4040
result.getEnclosingIRFunction() = this
4141
}
4242

43-
pragma[noinline]
44-
final UnmodeledDefinitionInstruction getUnmodeledDefinitionInstruction() {
45-
result.getEnclosingIRFunction() = this
46-
}
47-
4843
/**
4944
* Gets the single return instruction for this function.
5045
*/

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,6 @@ class CatchAnyInstruction extends CatchInstruction {
12291229
CatchAnyInstruction() { getOpcode() instanceof Opcode::CatchAny }
12301230
}
12311231

1232-
class UnmodeledDefinitionInstruction extends Instruction {
1233-
UnmodeledDefinitionInstruction() { getOpcode() instanceof Opcode::UnmodeledDefinition }
1234-
}
1235-
12361232
/**
12371233
* An instruction that initializes all escaped memory.
12381234
*/

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,9 @@ class Operand extends TOperand {
155155
* definition is not modeled in SSA.
156156
*/
157157
private string getDefinitionId() {
158-
exists(Instruction def |
159-
def = getAnyDef() and
160-
if def.isResultModeled() then result = def.getResultId() else result = "m?"
161-
)
158+
result = getAnyDef().getResultId()
159+
or
160+
not exists(getAnyDef()) and result = "m?"
162161
}
163162

164163
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ private module Cached {
6767

6868
cached
6969
predicate hasConflatedMemoryResult(Instruction instruction) {
70-
instruction instanceof UnmodeledDefinitionInstruction
71-
or
7270
instruction instanceof AliasedDefinitionInstruction
7371
or
7472
instruction.getOpcode() instanceof Opcode::InitializeNonLocal
@@ -127,14 +125,7 @@ private module Cached {
127125
oldInstruction = getOldInstruction(instruction) and
128126
oldOperand = oldInstruction.getAnOperand() and
129127
tag = oldOperand.getOperandTag() and
130-
(
131-
if exists(Alias::getOperandMemoryLocation(oldOperand))
132-
then hasMemoryOperandDefinition(oldInstruction, oldOperand, overlap, result)
133-
else (
134-
result = instruction.getEnclosingIRFunction().getUnmodeledDefinitionInstruction() and
135-
overlap instanceof MustTotallyOverlap
136-
)
137-
)
128+
hasMemoryOperandDefinition(oldInstruction, oldOperand, overlap, result)
138129
)
139130
or
140131
instruction = Chi(getOldInstruction(result)) and

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ module InstructionConsistency {
149149
}
150150

151151
/**
152-
* Holds if a memory operand is connected to a definition with an unmodeled result, other than
153-
* `UnmodeledDefinition` itself.
152+
* Holds if a memory operand is connected to a definition with an unmodeled result.
154153
*/
155154
query predicate memoryOperandDefinitionIsUnmodeled(
156155
Instruction instr, string message, IRFunction func, string funcText
@@ -159,9 +158,8 @@ module InstructionConsistency {
159158
operand = instr.getAnOperand() and
160159
def = operand.getAnyDef() and
161160
not def.isResultModeled() and
162-
not def instanceof UnmodeledDefinitionInstruction and
163161
message =
164-
"Memory operand definition has unmodeled result, but is not the `UnmodeledDefinition` instruction in function '$@'" and
162+
"Memory operand definition has unmodeled result in function '$@'" and
165163
func = instr.getEnclosingIRFunction() and
166164
funcText = Language::getIdentityString(func.getFunction())
167165
)
@@ -257,7 +255,6 @@ module InstructionConsistency {
257255
Operand useOperand, string message, IRFunction func, string funcText
258256
) {
259257
exists(IRBlock useBlock, int useIndex, Instruction defInstr, IRBlock defBlock, int defIndex |
260-
not defInstr instanceof UnmodeledDefinitionInstruction and
261258
pointOfEvaluation(useOperand, useBlock, useIndex) and
262259
defInstr = useOperand.getAnyDef() and
263260
(
@@ -306,8 +303,6 @@ module InstructionConsistency {
306303
private predicate shouldBeConflated(Instruction instr) {
307304
isOnAliasedDefinitionChain(instr)
308305
or
309-
instr instanceof UnmodeledDefinitionInstruction
310-
or
311306
instr.getOpcode() instanceof Opcode::InitializeNonLocal
312307
}
313308

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class IRFunction extends TIRFunction {
4040
result.getEnclosingIRFunction() = this
4141
}
4242

43-
pragma[noinline]
44-
final UnmodeledDefinitionInstruction getUnmodeledDefinitionInstruction() {
45-
result.getEnclosingIRFunction() = this
46-
}
47-
4843
/**
4944
* Gets the single return instruction for this function.
5045
*/

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,6 @@ class CatchAnyInstruction extends CatchInstruction {
12291229
CatchAnyInstruction() { getOpcode() instanceof Opcode::CatchAny }
12301230
}
12311231

1232-
class UnmodeledDefinitionInstruction extends Instruction {
1233-
UnmodeledDefinitionInstruction() { getOpcode() instanceof Opcode::UnmodeledDefinition }
1234-
}
1235-
12361232
/**
12371233
* An instruction that initializes all escaped memory.
12381234
*/

0 commit comments

Comments
 (0)