Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 057c634

Browse files
author
Robert Marsh
committed
C++: fix identical chi node operands
1 parent 17e1434 commit 057c634

5 files changed

Lines changed: 14 additions & 19 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,9 @@ module DefUse {
740740
block.getInstruction(index) = def and
741741
overlap = Alias::getOverlap(defLocation, useLocation) and
742742
if
743-
overlap instanceof MayPartiallyOverlap
743+
overlap instanceof MayPartiallyOverlap or
744+
def.getResultMemoryAccess() instanceof IndirectMayMemoryAccess or
745+
def.getResultMemoryAccess() instanceof BufferMayMemoryAccess
744746
then offset = (index * 2) + 1 // The use will be connected to the definition on the `Chi` instruction.
745747
else offset = index * 2 // The use will be connected to the definition on the original instruction.
746748
)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,9 @@ module DefUse {
740740
block.getInstruction(index) = def and
741741
overlap = Alias::getOverlap(defLocation, useLocation) and
742742
if
743-
overlap instanceof MayPartiallyOverlap
743+
overlap instanceof MayPartiallyOverlap or
744+
def.getResultMemoryAccess() instanceof IndirectMayMemoryAccess or
745+
def.getResultMemoryAccess() instanceof BufferMayMemoryAccess
744746
then offset = (index * 2) + 1 // The use will be connected to the definition on the `Chi` instruction.
745747
else offset = index * 2 // The use will be connected to the definition on the original instruction.
746748
)

cpp/ql/test/library-tests/ir/ir/aliased_ssa_sanity.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ duplicateOperand
88
missingPhiOperand
99
missingOperandType
1010
duplicateChiOperand
11-
| ir.cpp:1035:3:1035:12 | Chi: (const lambda [] type at line 1034, col. 21)... |
12-
| ir.cpp:1039:3:1039:21 | Chi: (const lambda [] type at line 1038, col. 30)... |
13-
| ir.cpp:1043:3:1043:23 | Chi: (const lambda [] type at line 1042, col. 32)... |
14-
| ir.cpp:1046:3:1046:14 | Chi: (const lambda [] type at line 1045, col. 23)... |
1511
instructionWithoutSuccessor
1612
ambiguousSuccessors
1713
unexplainedLoop

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -884,23 +884,23 @@ ssa.cpp:
884884
# 220| m0_8(unknown) = ^CallSideEffect : ~m0_1
885885
# 220| m0_9(unknown) = Chi : total:m0_1, partial:m0_8
886886
# 220| m0_10(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_3
887-
# 220| m0_11(Constructible) = Chi : total:m0_10, partial:m0_10
887+
# 220| m0_11(Constructible) = Chi : total:m0_4, partial:m0_10
888888
# 221| r0_12(glval<Constructible>) = VariableAddress[c] :
889889
# 221| r0_13(glval<unknown>) = FunctionAddress[g] :
890890
# 221| v0_14(void) = Call : func:r0_13, this:r0_12
891891
# 221| m0_15(unknown) = ^CallSideEffect : ~m0_9
892892
# 221| m0_16(unknown) = Chi : total:m0_9, partial:m0_15
893-
# 221| v0_17(void) = ^IndirectReadSideEffect[-1] : &:r0_12, m0_10
893+
# 221| v0_17(void) = ^IndirectReadSideEffect[-1] : &:r0_12, m0_11
894894
# 221| m0_18(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_12
895-
# 221| m0_19(Constructible) = Chi : total:m0_18, partial:m0_18
895+
# 221| m0_19(Constructible) = Chi : total:m0_11, partial:m0_18
896896
# 222| r0_20(glval<Constructible>) = VariableAddress[c] :
897897
# 222| r0_21(glval<unknown>) = FunctionAddress[g] :
898898
# 222| v0_22(void) = Call : func:r0_21, this:r0_20
899899
# 222| m0_23(unknown) = ^CallSideEffect : ~m0_16
900900
# 222| m0_24(unknown) = Chi : total:m0_16, partial:m0_23
901-
# 222| v0_25(void) = ^IndirectReadSideEffect[-1] : &:r0_20, m0_18
901+
# 222| v0_25(void) = ^IndirectReadSideEffect[-1] : &:r0_20, m0_19
902902
# 222| m0_26(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_20
903-
# 222| m0_27(Constructible) = Chi : total:m0_26, partial:m0_26
903+
# 222| m0_27(Constructible) = Chi : total:m0_19, partial:m0_26
904904
# 223| r0_28(glval<Constructible>) = VariableAddress[c2] :
905905
# 223| m0_29(Constructible) = Uninitialized[c2] : &:r0_28
906906
# 223| r0_30(glval<unknown>) = FunctionAddress[Constructible] :
@@ -909,15 +909,15 @@ ssa.cpp:
909909
# 223| m0_33(unknown) = ^CallSideEffect : ~m0_24
910910
# 223| m0_34(unknown) = Chi : total:m0_24, partial:m0_33
911911
# 223| m0_35(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_28
912-
# 223| m0_36(Constructible) = Chi : total:m0_35, partial:m0_35
912+
# 223| m0_36(Constructible) = Chi : total:m0_29, partial:m0_35
913913
# 224| r0_37(glval<Constructible>) = VariableAddress[c2] :
914914
# 224| r0_38(glval<unknown>) = FunctionAddress[g] :
915915
# 224| v0_39(void) = Call : func:r0_38, this:r0_37
916916
# 224| m0_40(unknown) = ^CallSideEffect : ~m0_34
917917
# 224| m0_41(unknown) = Chi : total:m0_34, partial:m0_40
918-
# 224| v0_42(void) = ^IndirectReadSideEffect[-1] : &:r0_37, m0_35
918+
# 224| v0_42(void) = ^IndirectReadSideEffect[-1] : &:r0_37, m0_36
919919
# 224| m0_43(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_37
920-
# 224| m0_44(Constructible) = Chi : total:m0_43, partial:m0_43
920+
# 224| m0_44(Constructible) = Chi : total:m0_36, partial:m0_43
921921
# 225| v0_45(void) = NoOp :
922922
# 219| v0_46(void) = ReturnVoid :
923923
# 219| v0_47(void) = UnmodeledUse : mu*

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_sanity.expected

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ duplicateOperand
44
missingPhiOperand
55
missingOperandType
66
duplicateChiOperand
7-
| ssa.cpp:220:19:220:20 | Chi: call to Constructible |
8-
| ssa.cpp:221:3:221:3 | Chi: c |
9-
| ssa.cpp:222:3:222:3 | Chi: c |
10-
| ssa.cpp:223:21:223:37 | Chi: call to Constructible |
11-
| ssa.cpp:224:3:224:4 | Chi: c2 |
127
instructionWithoutSuccessor
138
ambiguousSuccessors
149
unexplainedLoop

0 commit comments

Comments
 (0)