Skip to content

Commit 44bc6d7

Browse files
author
Robert Marsh
committed
C++/C#: add NonPhiMemoryOperand union type
This fixes a performance issue where the whole MemoryOperand table was scanned in some predicates that used only NonPhiMemoryOperand
1 parent 5d2a553 commit 44bc6d7

File tree

7 files changed

+12
-5
lines changed

7 files changed

+12
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
272272
/**
273273
* A memory operand other than the operand of a `Phi` instruction.
274274
*/
275-
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand {
275+
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
276276
override MemoryOperandTag tag;
277277

278278
NonPhiMemoryOperand() {

cpp/ql/src/semmle/code/cpp/ir/implementation/internal/TOperand.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ module RawOperands {
100100

101101
class TChiOperand = Internal::TNoOperand;
102102

103+
class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand;
104+
103105
/**
104106
* Returns the Phi operand with the specified parameters.
105107
*/
@@ -129,6 +131,7 @@ module UnaliasedSSAOperands {
129131

130132
class TChiOperand = Internal::TNoOperand;
131133

134+
class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand;
132135
/**
133136
* Returns the Phi operand with the specified parameters.
134137
*/
@@ -158,6 +161,7 @@ module AliasedSSAOperands {
158161

159162
class TChiOperand = Internal::TAliasedChiOperand;
160163

164+
class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand;
161165
/**
162166
* Returns the Phi operand with the specified parameters.
163167
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
272272
/**
273273
* A memory operand other than the operand of a `Phi` instruction.
274274
*/
275-
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand {
275+
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
276276
override MemoryOperandTag tag;
277277

278278
NonPhiMemoryOperand() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
272272
/**
273273
* A memory operand other than the operand of a `Phi` instruction.
274274
*/
275-
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand {
275+
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
276276
override MemoryOperandTag tag;
277277

278278
NonPhiMemoryOperand() {

csharp/ql/src/experimental/ir/implementation/internal/TOperand.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ module RawOperands {
8080

8181
class TChiOperand = Internal::TNoOperand;
8282

83+
class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand;
8384
/**
8485
* Returns the Phi operand with the specified parameters.
8586
*/
@@ -109,6 +110,8 @@ module UnaliasedSSAOperands {
109110

110111
class TChiOperand = Internal::TNoOperand;
111112

113+
class TNonPhiMemoryOperand = TNonSSAMemoryOperand or TChiOperand;
114+
112115
/**
113116
* Returns the Phi operand with the specified parameters.
114117
*/

csharp/ql/src/experimental/ir/implementation/raw/Operand.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
272272
/**
273273
* A memory operand other than the operand of a `Phi` instruction.
274274
*/
275-
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand {
275+
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
276276
override MemoryOperandTag tag;
277277

278278
NonPhiMemoryOperand() {

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class RegisterOperand extends NonPhiOperand, TRegisterOperand {
272272
/**
273273
* A memory operand other than the operand of a `Phi` instruction.
274274
*/
275-
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand {
275+
class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOperand {
276276
override MemoryOperandTag tag;
277277

278278
NonPhiMemoryOperand() {

0 commit comments

Comments
 (0)