Skip to content

Commit 5d3f252

Browse files
author
Dave Bartolomeo
committed
C++/C#: Remove UnmodeledUse instruction
1 parent 7f2c6dd commit 5d3f252

33 files changed

+829
-1288
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ private newtype TOpcode =
6161
TReThrow() or
6262
TUnwind() or
6363
TUnmodeledDefinition() or
64-
TUnmodeledUse() or
6564
TAliasedDefinition() or
6665
TInitializeNonLocal() or
6766
TAliasedUse() or
@@ -587,12 +586,6 @@ module Opcode {
587586
}
588587
}
589588

590-
class UnmodeledUse extends Opcode, TUnmodeledUse {
591-
final override string toString() { result = "UnmodeledUse" }
592-
593-
final override predicate hasOperandInternal(OperandTag tag) { none() }
594-
}
595-
596589
class AliasedDefinition extends Opcode, TAliasedDefinition {
597590
final override string toString() { result = "AliasedDefinition" }
598591

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ class IRBlockBase extends TIRBlock {
3131
config.shouldEvaluateDebugStringsForFunction(this.getEnclosingFunction())
3232
) and
3333
this =
34-
rank[result + 1](IRBlock funcBlock |
35-
funcBlock.getEnclosingFunction() = getEnclosingFunction()
34+
rank[result + 1](IRBlock funcBlock, int sortOverride |
35+
funcBlock.getEnclosingFunction() = getEnclosingFunction() and
36+
// Ensure that the block containing `EnterFunction` always comes first.
37+
if funcBlock.getFirstInstruction() instanceof EnterFunctionInstruction
38+
then sortOverride = 0
39+
else sortOverride = 1
3640
|
37-
funcBlock order by funcBlock.getUniqueId()
41+
funcBlock order by sortOverride, funcBlock.getUniqueId()
3842
)
3943
}
4044

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ module InstructionConsistency {
257257
Operand useOperand, string message, IRFunction func, string funcText
258258
) {
259259
exists(IRBlock useBlock, int useIndex, Instruction defInstr, IRBlock defBlock, int defIndex |
260-
not useOperand.getUse() instanceof UnmodeledUseInstruction and
261260
not defInstr instanceof UnmodeledDefinitionInstruction and
262261
pointOfEvaluation(useOperand, useBlock, useIndex) and
263262
defInstr = useOperand.getAnyDef() and

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
@@ -45,11 +45,6 @@ class IRFunction extends TIRFunction {
4545
result.getEnclosingIRFunction() = this
4646
}
4747

48-
pragma[noinline]
49-
final UnmodeledUseInstruction getUnmodeledUseInstruction() {
50-
result.getEnclosingIRFunction() = this
51-
}
52-
5348
/**
5449
* Gets the single return instruction for this function.
5550
*/

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ class Instruction extends Construction::TInstruction {
320320
/**
321321
* Holds if the result of this instruction is precisely modeled in SSA. Always
322322
* holds for a register result. For a memory result, a modeled result is
323-
* connected to its actual uses. An unmodeled result is connected to the
324-
* `UnmodeledUse` instruction.
323+
* connected to its actual uses. An unmodeled result has no uses.
325324
*
326325
* For example:
327326
* ```
@@ -1248,12 +1247,6 @@ class AliasedUseInstruction extends Instruction {
12481247
AliasedUseInstruction() { getOpcode() instanceof Opcode::AliasedUse }
12491248
}
12501249

1251-
class UnmodeledUseInstruction extends Instruction {
1252-
UnmodeledUseInstruction() { getOpcode() instanceof Opcode::UnmodeledUse }
1253-
1254-
override string getOperandsString() { result = "mu*" }
1255-
}
1256-
12571250
/**
12581251
* An instruction representing the choice of one of multiple input values based on control flow.
12591252
*

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ class IRBlockBase extends TIRBlock {
3131
config.shouldEvaluateDebugStringsForFunction(this.getEnclosingFunction())
3232
) and
3333
this =
34-
rank[result + 1](IRBlock funcBlock |
35-
funcBlock.getEnclosingFunction() = getEnclosingFunction()
34+
rank[result + 1](IRBlock funcBlock, int sortOverride |
35+
funcBlock.getEnclosingFunction() = getEnclosingFunction() and
36+
// Ensure that the block containing `EnterFunction` always comes first.
37+
if funcBlock.getFirstInstruction() instanceof EnterFunctionInstruction
38+
then sortOverride = 0
39+
else sortOverride = 1
3640
|
37-
funcBlock order by funcBlock.getUniqueId()
41+
funcBlock order by sortOverride, funcBlock.getUniqueId()
3842
)
3943
}
4044

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ module InstructionConsistency {
257257
Operand useOperand, string message, IRFunction func, string funcText
258258
) {
259259
exists(IRBlock useBlock, int useIndex, Instruction defInstr, IRBlock defBlock, int defIndex |
260-
not useOperand.getUse() instanceof UnmodeledUseInstruction and
261260
not defInstr instanceof UnmodeledDefinitionInstruction and
262261
pointOfEvaluation(useOperand, useBlock, useIndex) and
263262
defInstr = useOperand.getAnyDef() and

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
@@ -45,11 +45,6 @@ class IRFunction extends TIRFunction {
4545
result.getEnclosingIRFunction() = this
4646
}
4747

48-
pragma[noinline]
49-
final UnmodeledUseInstruction getUnmodeledUseInstruction() {
50-
result.getEnclosingIRFunction() = this
51-
}
52-
5348
/**
5449
* Gets the single return instruction for this function.
5550
*/

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ class Instruction extends Construction::TInstruction {
320320
/**
321321
* Holds if the result of this instruction is precisely modeled in SSA. Always
322322
* holds for a register result. For a memory result, a modeled result is
323-
* connected to its actual uses. An unmodeled result is connected to the
324-
* `UnmodeledUse` instruction.
323+
* connected to its actual uses. An unmodeled result has no uses.
325324
*
326325
* For example:
327326
* ```
@@ -1248,12 +1247,6 @@ class AliasedUseInstruction extends Instruction {
12481247
AliasedUseInstruction() { getOpcode() instanceof Opcode::AliasedUse }
12491248
}
12501249

1251-
class UnmodeledUseInstruction extends Instruction {
1252-
UnmodeledUseInstruction() { getOpcode() instanceof Opcode::UnmodeledUse }
1253-
1254-
override string getOperandsString() { result = "mu*" }
1255-
}
1256-
12571250
/**
12581251
* An instruction representing the choice of one of multiple input values based on control flow.
12591252
*

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionTag.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ newtype TInstructionTag =
2929
ReturnTag() or
3030
ExitFunctionTag() or
3131
UnmodeledDefinitionTag() or
32-
UnmodeledUseTag() or
3332
AliasedDefinitionTag() or
3433
InitializeNonLocalTag() or
3534
AliasedUseTag() or
@@ -129,8 +128,6 @@ string getInstructionTagId(TInstructionTag tag) {
129128
or
130129
tag = UnmodeledDefinitionTag() and result = "UnmodeledDef"
131130
or
132-
tag = UnmodeledUseTag() and result = "UnmodeledUse"
133-
or
134131
tag = AliasedDefinitionTag() and result = "AliasedDef"
135132
or
136133
tag = InitializeNonLocalTag() and result = "InitNonLocal"

0 commit comments

Comments
 (0)