Skip to content

Commit 9f228f5

Browse files
committed
Binary: Delete the 'InstrRef' opcode and don't generate IR using it.
1 parent 842a500 commit 9f228f5

9 files changed

Lines changed: 38 additions & 231 deletions

File tree

binary/ql/lib/semmle/code/binary/ast/ir/IR.qll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,6 @@ private module FinalInstruction {
353353
JumpTargetOperand getJumpTargetOperand() { result = super.getJumpTargetOperand() }
354354
}
355355

356-
class InstrRefInstruction extends Instruction instanceof Instruction::InstrRefInstruction {
357-
Instruction getReferencedInstruction() { result = super.getReferencedInstruction() }
358-
}
359-
360356
class CopyInstruction extends Instruction instanceof Instruction::CopyInstruction {
361357
UnaryOperand getOperand() { result = super.getOperand() }
362358
}

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/Instruction.qll

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Instruction extends TInstruction {
3232
Operand getFirstOperand() {
3333
exists(OperandTag operandTag |
3434
result = this.getOperand(operandTag) and
35-
not exists(operandTag.getPredecessorTag())
35+
not exists(this.getOperand(operandTag.getPredecessorTag()))
3636
)
3737
}
3838

@@ -171,21 +171,6 @@ class CallInstruction extends Instruction {
171171
override string getImmediateValue() { result = this.getStaticTarget().getName() }
172172
}
173173

174-
class InstrRefInstruction extends Instruction {
175-
override Opcode::InstrRef opcode;
176-
177-
Instruction getReferencedInstruction() { result = te.getReferencedInstruction(tag) }
178-
179-
final override string getImmediateValue() {
180-
exists(Instruction ref | ref = this.getReferencedInstruction() |
181-
result = ref.getResultVariable().toString()
182-
or
183-
not exists(ref.getResultVariable()) and
184-
result = "<reference to instruction without result>"
185-
)
186-
}
187-
}
188-
189174
class ExternalRefInstruction extends Instruction {
190175
override Opcode::ExternalRef opcode;
191176

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/InstructionTag.qll

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ private import semmle.code.binary.ast.internal.CilInstructions
55
newtype TInstructionTag =
66
SingleTag() or
77
FunEntryTag() or
8-
X86JumpInstrRefTag() or
9-
X86JumpTag() or
10-
X86CJumpInstrRefTag() or
11-
X86CJumpTag() or
128
WriteTag() or
139
InitFramePtrTag() or
1410
InitStackPtrTag() or
@@ -51,13 +47,9 @@ newtype TInstructionTag =
5147
CilRelSubTag() or
5248
CilRelCJumpTag() or
5349
CilRelConstTag(Boolean b) or
54-
CilRelRefTag() or
55-
CilBoolBranchRefTag() or
5650
CilBoolBranchSubTag() or
5751
CilBoolBranchConstTag() or
5852
CilBoolBranchCJumpTag() or
59-
CilUnconditionalBranchTag() or
60-
CilUnconditionalBranchRefTag() or
6153
CilCallTag() or
6254
CilCallTargetTag() or
6355
CilLdindLoadTag() or
@@ -71,18 +63,6 @@ class InstructionTag extends TInstructionTag {
7163
this = FunEntryTag() and
7264
result = "FunEntry"
7365
or
74-
this = X86JumpInstrRefTag() and
75-
result = "X86JumpInstrRef"
76-
or
77-
this = X86JumpTag() and
78-
result = "X86Jump"
79-
or
80-
this = X86CJumpInstrRefTag() and
81-
result = "X86CJumpInstrRef"
82-
or
83-
this = X86CJumpTag() and
84-
result = "X86CJump"
85-
or
8666
this = WriteTag() and
8767
result = "Write"
8868
or
@@ -196,12 +176,6 @@ class InstructionTag extends TInstructionTag {
196176
result = "CilRelConst(" + b.toString() + ")"
197177
)
198178
or
199-
this = CilRelRefTag() and
200-
result = "CilRelRef"
201-
or
202-
this = CilBoolBranchRefTag() and
203-
result = "CilBoolBranchRef"
204-
or
205179
this = CilBoolBranchSubTag() and
206180
result = "CilBoolBranchSub"
207181
or
@@ -211,12 +185,6 @@ class InstructionTag extends TInstructionTag {
211185
this = CilBoolBranchCJumpTag() and
212186
result = "CilBoolBranchCJump"
213187
or
214-
this = CilUnconditionalBranchTag() and
215-
result = "CilUnconditionalBranch"
216-
or
217-
this = CilUnconditionalBranchRefTag() and
218-
result = "CilUnconditionalBranchRef"
219-
or
220188
this = CilCallTag() and
221189
result = "CilCall"
222190
or

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/TempVariableTag.qll

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
newtype TTempVariableTag =
2-
X86JumpInstrRefVarTag() or
3-
X86CJumpInstrRefVarTag() or
42
TestVarTag() or
53
ZeroVarTag() or
64
ImmediateOperandVarTag() or
@@ -23,11 +21,9 @@ newtype TTempVariableTag =
2321
CilLdLocVarTag() or
2422
CilBinaryVarTag() or
2523
CilRelSubVarTag() or
26-
CilRelRefVarTag() or
2724
CilRelVarTag() or
2825
CilBoolBranchConstVarTag() or
2926
CilBoolBranchSubVarTag() or
30-
CilBoolBranchRefVarTag() or
3127
CilUnconditionalBranchRefVarTag() or
3228
CallReturnValueTag() or
3329
CilCallTargetVarTag() or
@@ -37,12 +33,6 @@ newtype TTempVariableTag =
3733

3834
class TempVariableTag extends TTempVariableTag {
3935
string toString() {
40-
this = X86JumpInstrRefVarTag() and
41-
result = "j_ir"
42-
or
43-
this = X86CJumpInstrRefVarTag() and
44-
result = "cj_ir"
45-
or
4636
this = TestVarTag() and
4737
result = "t"
4838
or
@@ -109,9 +99,6 @@ class TempVariableTag extends TTempVariableTag {
10999
this = CilRelSubVarTag() and
110100
result = "r_s"
111101
or
112-
this = CilRelRefVarTag() and
113-
result = "ref"
114-
or
115102
this = CilRelVarTag() and
116103
result = "r"
117104
or
@@ -124,9 +111,6 @@ class TempVariableTag extends TTempVariableTag {
124111
this = CilUnconditionalBranchRefVarTag() and
125112
result = "cub_ir"
126113
or
127-
this = CilBoolBranchRefVarTag() and
128-
result = "cbb_ir"
129-
or
130114
this = CallReturnValueTag() and
131115
result = "call_ret"
132116
or

binary/ql/lib/semmle/code/binary/ast/ir/internal/Instruction0/TranslatedElement.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,6 @@ abstract class TranslatedElement extends TTranslatedElement {
217217
*/
218218
string getExternalName(InstructionTag tag) { none() }
219219

220-
/**
221-
* Gets the instruction referenced by the instruction with the given tag. This `tag` must refer to
222-
* an `InstrRef` (that is, an instruction for which `hasInstruction(Opcode::InstrRef, tag, _)` holds.)
223-
*/
224-
Instruction getReferencedInstruction(InstructionTag tag) { none() }
225-
226220
/**
227221
* Gets the raw element that this translated element is a translation of.
228222
*

0 commit comments

Comments
 (0)