Skip to content

Commit 35594ea

Browse files
committed
C++: fix bad join order in phi node sharing
1 parent 5406783 commit 35594ea

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-33
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,10 @@ private module Cached {
6565
instr = reusedPhiInstruction(_) and
6666
// Check that the phi instruction is *not* degenerate, but we can't use
6767
// getDegeneratePhiOperand in the first stage with phi instyructions
68-
exists(
69-
OldIR::PhiInputOperand operand1, OldIR::PhiInputOperand operand2,
70-
OldInstruction oldInstruction
71-
|
72-
oldInstruction = instr and
73-
operand1 = oldInstruction.(OldIR::PhiInstruction).getAnInputOperand() and
74-
operand1.getPredecessorBlock() instanceof OldBlock and
75-
operand2 = oldInstruction.(OldIR::PhiInstruction).getAnInputOperand() and
76-
operand2.getPredecessorBlock() instanceof OldBlock and
77-
operand1 != operand2
78-
)
68+
not exists(unique(OldIR::PhiInputOperand operand |
69+
operand = instr.(OldIR::PhiInstruction).getAnInputOperand() and
70+
operand.getPredecessorBlock() instanceof OldBlock
71+
))
7972
or
8073
instr instanceof TChiInstruction
8174
or

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,10 @@ private module Cached {
6565
instr = reusedPhiInstruction(_) and
6666
// Check that the phi instruction is *not* degenerate, but we can't use
6767
// getDegeneratePhiOperand in the first stage with phi instyructions
68-
exists(
69-
OldIR::PhiInputOperand operand1, OldIR::PhiInputOperand operand2,
70-
OldInstruction oldInstruction
71-
|
72-
oldInstruction = instr and
73-
operand1 = oldInstruction.(OldIR::PhiInstruction).getAnInputOperand() and
74-
operand1.getPredecessorBlock() instanceof OldBlock and
75-
operand2 = oldInstruction.(OldIR::PhiInstruction).getAnInputOperand() and
76-
operand2.getPredecessorBlock() instanceof OldBlock and
77-
operand1 != operand2
78-
)
68+
not exists(unique(OldIR::PhiInputOperand operand |
69+
operand = instr.(OldIR::PhiInstruction).getAnInputOperand() and
70+
operand.getPredecessorBlock() instanceof OldBlock
71+
))
7972
or
8073
instr instanceof TChiInstruction
8174
or

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,10 @@ private module Cached {
6565
instr = reusedPhiInstruction(_) and
6666
// Check that the phi instruction is *not* degenerate, but we can't use
6767
// getDegeneratePhiOperand in the first stage with phi instyructions
68-
exists(
69-
OldIR::PhiInputOperand operand1, OldIR::PhiInputOperand operand2,
70-
OldInstruction oldInstruction
71-
|
72-
oldInstruction = instr and
73-
operand1 = oldInstruction.(OldIR::PhiInstruction).getAnInputOperand() and
74-
operand1.getPredecessorBlock() instanceof OldBlock and
75-
operand2 = oldInstruction.(OldIR::PhiInstruction).getAnInputOperand() and
76-
operand2.getPredecessorBlock() instanceof OldBlock and
77-
operand1 != operand2
78-
)
68+
not exists(unique(OldIR::PhiInputOperand operand |
69+
operand = instr.(OldIR::PhiInstruction).getAnInputOperand() and
70+
operand.getPredecessorBlock() instanceof OldBlock
71+
))
7972
or
8073
instr instanceof TChiInstruction
8174
or

0 commit comments

Comments
 (0)