From a0df7d22cdb956657d73d2e23c0f5d8bb79c5bcf Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Tue, 4 Apr 2023 10:08:18 +0100 Subject: [PATCH] C++: Add tests for designated initializers with repetitions. --- .../ir/ssa/aliased_ssa_consistency.expected | 3 + .../aliased_ssa_consistency_unsound.expected | 3 + .../ir/ssa/aliased_ssa_ir.expected | 120 ++++++++++++++++++ .../ir/ssa/aliased_ssa_ir_unsound.expected | 120 ++++++++++++++++++ cpp/ql/test/library-tests/ir/ssa/ssa.c | 8 ++ cpp/ql/test/library-tests/ir/ssa/ssa.cpp | 6 +- .../ir/ssa/unaliased_ssa_consistency.expected | 3 + ...unaliased_ssa_consistency_unsound.expected | 3 + .../ir/ssa/unaliased_ssa_ir.expected | 109 ++++++++++++++++ .../ir/ssa/unaliased_ssa_ir_unsound.expected | 109 ++++++++++++++++ 10 files changed, 483 insertions(+), 1 deletion(-) create mode 100644 cpp/ql/test/library-tests/ir/ssa/ssa.c diff --git a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency.expected b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency.expected index 79887fffc1f..dca4c18ad29 100644 --- a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency.expected +++ b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency.expected @@ -7,6 +7,9 @@ duplicateChiOperand sideEffectWithoutPrimary instructionWithoutSuccessor ambiguousSuccessors +| ssa.c:3:14:3:16 | Uninitialized: definition of foo | Instruction 'Uninitialized: definition of foo' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:2:6:2:22 | void named_designators() | void named_designators() | +| ssa.c:7:13:7:37 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:6:6:6:25 | void repeated_designators() | void repeated_designators() | +| ssa.cpp:418:16:418:46 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.cpp:417:6:417:29 | void nested_array_designators() | void nested_array_designators() | unexplainedLoop unnecessaryPhiInstruction memoryOperandDefinitionIsUnmodeled diff --git a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency_unsound.expected b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency_unsound.expected index 79887fffc1f..dca4c18ad29 100644 --- a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency_unsound.expected +++ b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency_unsound.expected @@ -7,6 +7,9 @@ duplicateChiOperand sideEffectWithoutPrimary instructionWithoutSuccessor ambiguousSuccessors +| ssa.c:3:14:3:16 | Uninitialized: definition of foo | Instruction 'Uninitialized: definition of foo' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:2:6:2:22 | void named_designators() | void named_designators() | +| ssa.c:7:13:7:37 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:6:6:6:25 | void repeated_designators() | void repeated_designators() | +| ssa.cpp:418:16:418:46 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.cpp:417:6:417:29 | void nested_array_designators() | void nested_array_designators() | unexplainedLoop unnecessaryPhiInstruction memoryOperandDefinitionIsUnmodeled diff --git a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected index 7f76af075a7..e245ba140b7 100644 --- a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected +++ b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected @@ -1,3 +1,78 @@ +ssa.c: +# 2| void named_designators() +# 2| Block 0 +# 2| v2_1(void) = EnterFunction : +# 2| m2_2(unknown) = AliasedDefinition : +# 2| m2_3(unknown) = InitializeNonLocal : +# 2| m2_4(unknown) = Chi : total:m2_2, partial:m2_3 +# 3| r3_1(glval) = VariableAddress[foo] : +# 3| m3_2(Foo) = Uninitialized[foo] : &:r3_1 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[1234] : +# 3| m3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| m3_13(Foo) = Chi : total:m3_2, partial:m3_11 +# 3| r3_15(int) = Constant[1] : +# 3| r3_17(glval) = PointerAdd[4] : r3_3, r3_15 +# 3| r3_19(int) = Constant[0] : +# 3| m3_21(int) = Store[?] : &:r3_17, r3_19 +# 3| m3_23(Foo) = Chi : total:m3_13, partial:m3_21 +#-----| Goto -> Block 3 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[0] : +# 3| m3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| m3_13(Foo) = Chi : total:m3_2, partial:m3_11 +# 3| r3_15(int) = Constant[1] : +# 3| r3_17(glval) = PointerAdd[4] : r3_3, r3_15 +# 3| r3_19(int) = Constant[5678] : +# 3| m3_21(int) = Store[?] : &:r3_17, r3_19 +# 3| m3_23(Foo) = Chi : total:m3_13, partial:m3_21 +#-----| Goto -> Block 3 + +# 4| Block 3 +# 4| v4_1(void) = NoOp : +# 2| v2_5(void) = ReturnVoid : +# 2| v2_6(void) = AliasedUse : m2_3 +# 2| v2_7(void) = ExitFunction : + +# 6| void repeated_designators() +# 6| Block 0 +# 6| v6_1(void) = EnterFunction : +# 6| m6_2(unknown) = AliasedDefinition : +# 6| m6_3(unknown) = InitializeNonLocal : +# 6| m6_4(unknown) = Chi : total:m6_2, partial:m6_3 +# 7| r7_1(glval) = VariableAddress[x] : +# 7| m7_2(int[1]) = Uninitialized[x] : &:r7_1 +# 7| r7_3(int) = Constant[0] : +# 7| r7_4(glval) = PointerAdd[4] : r7_1, r7_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 7| Block 1 +# 7| r7_5(int) = Constant[1234] : +# 7| m7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 7| Block 1 +# 7| r7_5(int) = Constant[5678] : +# 7| m7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 8| Block 3 +# 8| v8_1(void) = NoOp : +# 6| v6_5(void) = ReturnVoid : +# 6| v6_6(void) = AliasedUse : m6_3 +# 6| v6_7(void) = ExitFunction : + ssa.cpp: # 13| int ChiPhiNode(Point*, bool, bool) # 13| Block 0 @@ -1892,3 +1967,48 @@ ssa.cpp: # 401| v401_13(void) = ReturnVoid : # 401| v401_14(void) = AliasedUse : ~m408_10 # 401| v401_15(void) = ExitFunction : + +# 417| void nested_array_designators() +# 417| Block 0 +# 417| v417_1(void) = EnterFunction : +# 417| m417_2(unknown) = AliasedDefinition : +# 417| m417_3(unknown) = InitializeNonLocal : +# 417| m417_4(unknown) = Chi : total:m417_2, partial:m417_3 +# 418| r418_1(glval) = VariableAddress[x] : +# 418| m418_2(int[1][2]) = Uninitialized[x] : &:r418_1 +# 418| r418_3(int) = Constant[0] : +# 418| r418_4(glval) = PointerAdd[8] : r418_1, r418_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[0] : +# 418| m418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| m418_13(int[1][2]) = Chi : total:m418_2, partial:m418_11 +# 418| r418_15(int) = Constant[1] : +# 418| r418_17(glval) = PointerAdd[4] : r418_4, r418_15 +# 418| r418_19(int) = Constant[5678] : +# 418| m418_21(int) = Store[?] : &:r418_17, r418_19 +# 418| m418_23(int[1][2]) = Chi : total:m418_13, partial:m418_21 +#-----| Goto -> Block 3 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[1234] : +# 418| m418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| m418_13(int[1][2]) = Chi : total:m418_2, partial:m418_11 +# 418| r418_15(int) = Constant[1] : +# 418| r418_17(glval) = PointerAdd[4] : r418_4, r418_15 +# 418| r418_19(int) = Constant[0] : +# 418| m418_21(int) = Store[?] : &:r418_17, r418_19 +# 418| m418_23(int[1][2]) = Chi : total:m418_13, partial:m418_21 +#-----| Goto -> Block 3 + +# 419| Block 3 +# 419| v419_1(void) = NoOp : +# 417| v417_5(void) = ReturnVoid : +# 417| v417_6(void) = AliasedUse : m417_3 +# 417| v417_7(void) = ExitFunction : diff --git a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir_unsound.expected b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir_unsound.expected index 1ad86dc0da0..e3421a02ea9 100644 --- a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir_unsound.expected +++ b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir_unsound.expected @@ -1,3 +1,78 @@ +ssa.c: +# 2| void named_designators() +# 2| Block 0 +# 2| v2_1(void) = EnterFunction : +# 2| m2_2(unknown) = AliasedDefinition : +# 2| m2_3(unknown) = InitializeNonLocal : +# 2| m2_4(unknown) = Chi : total:m2_2, partial:m2_3 +# 3| r3_1(glval) = VariableAddress[foo] : +# 3| m3_2(Foo) = Uninitialized[foo] : &:r3_1 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[1234] : +# 3| m3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| m3_13(Foo) = Chi : total:m3_2, partial:m3_11 +# 3| r3_15(int) = Constant[1] : +# 3| r3_17(glval) = PointerAdd[4] : r3_3, r3_15 +# 3| r3_19(int) = Constant[0] : +# 3| m3_21(int) = Store[?] : &:r3_17, r3_19 +# 3| m3_23(Foo) = Chi : total:m3_13, partial:m3_21 +#-----| Goto -> Block 3 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[0] : +# 3| m3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| m3_13(Foo) = Chi : total:m3_2, partial:m3_11 +# 3| r3_15(int) = Constant[1] : +# 3| r3_17(glval) = PointerAdd[4] : r3_3, r3_15 +# 3| r3_19(int) = Constant[5678] : +# 3| m3_21(int) = Store[?] : &:r3_17, r3_19 +# 3| m3_23(Foo) = Chi : total:m3_13, partial:m3_21 +#-----| Goto -> Block 3 + +# 4| Block 3 +# 4| v4_1(void) = NoOp : +# 2| v2_5(void) = ReturnVoid : +# 2| v2_6(void) = AliasedUse : m2_3 +# 2| v2_7(void) = ExitFunction : + +# 6| void repeated_designators() +# 6| Block 0 +# 6| v6_1(void) = EnterFunction : +# 6| m6_2(unknown) = AliasedDefinition : +# 6| m6_3(unknown) = InitializeNonLocal : +# 6| m6_4(unknown) = Chi : total:m6_2, partial:m6_3 +# 7| r7_1(glval) = VariableAddress[x] : +# 7| m7_2(int[1]) = Uninitialized[x] : &:r7_1 +# 7| r7_3(int) = Constant[0] : +# 7| r7_4(glval) = PointerAdd[4] : r7_1, r7_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 7| Block 1 +# 7| r7_5(int) = Constant[1234] : +# 7| m7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 7| Block 1 +# 7| r7_5(int) = Constant[5678] : +# 7| m7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 8| Block 3 +# 8| v8_1(void) = NoOp : +# 6| v6_5(void) = ReturnVoid : +# 6| v6_6(void) = AliasedUse : m6_3 +# 6| v6_7(void) = ExitFunction : + ssa.cpp: # 13| int ChiPhiNode(Point*, bool, bool) # 13| Block 0 @@ -1881,3 +1956,48 @@ ssa.cpp: # 401| v401_13(void) = ReturnVoid : # 401| v401_14(void) = AliasedUse : ~m408_10 # 401| v401_15(void) = ExitFunction : + +# 417| void nested_array_designators() +# 417| Block 0 +# 417| v417_1(void) = EnterFunction : +# 417| m417_2(unknown) = AliasedDefinition : +# 417| m417_3(unknown) = InitializeNonLocal : +# 417| m417_4(unknown) = Chi : total:m417_2, partial:m417_3 +# 418| r418_1(glval) = VariableAddress[x] : +# 418| m418_2(int[1][2]) = Uninitialized[x] : &:r418_1 +# 418| r418_3(int) = Constant[0] : +# 418| r418_4(glval) = PointerAdd[8] : r418_1, r418_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[0] : +# 418| m418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| m418_13(int[1][2]) = Chi : total:m418_2, partial:m418_11 +# 418| r418_15(int) = Constant[1] : +# 418| r418_17(glval) = PointerAdd[4] : r418_4, r418_15 +# 418| r418_19(int) = Constant[5678] : +# 418| m418_21(int) = Store[?] : &:r418_17, r418_19 +# 418| m418_23(int[1][2]) = Chi : total:m418_13, partial:m418_21 +#-----| Goto -> Block 3 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[1234] : +# 418| m418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| m418_13(int[1][2]) = Chi : total:m418_2, partial:m418_11 +# 418| r418_15(int) = Constant[1] : +# 418| r418_17(glval) = PointerAdd[4] : r418_4, r418_15 +# 418| r418_19(int) = Constant[0] : +# 418| m418_21(int) = Store[?] : &:r418_17, r418_19 +# 418| m418_23(int[1][2]) = Chi : total:m418_13, partial:m418_21 +#-----| Goto -> Block 3 + +# 419| Block 3 +# 419| v419_1(void) = NoOp : +# 417| v417_5(void) = ReturnVoid : +# 417| v417_6(void) = AliasedUse : m417_3 +# 417| v417_7(void) = ExitFunction : diff --git a/cpp/ql/test/library-tests/ir/ssa/ssa.c b/cpp/ql/test/library-tests/ir/ssa/ssa.c new file mode 100644 index 00000000000..d9fe4fe9d4e --- /dev/null +++ b/cpp/ql/test/library-tests/ir/ssa/ssa.c @@ -0,0 +1,8 @@ +struct Foo { int x[2]; }; +void named_designators() { + struct Foo foo = {.x[0] = 1234, .x[1] = 5678}; +} + +void repeated_designators() { + int x[1] = {[0] = 1234, [0] = 5678}; +} \ No newline at end of file diff --git a/cpp/ql/test/library-tests/ir/ssa/ssa.cpp b/cpp/ql/test/library-tests/ir/ssa/ssa.cpp index 98c33c3eddf..d356f0dc1f7 100644 --- a/cpp/ql/test/library-tests/ir/ssa/ssa.cpp +++ b/cpp/ql/test/library-tests/ir/ssa/ssa.cpp @@ -412,4 +412,8 @@ void vla(int n1, int n2, int n3, bool b1) { } else { int b[n2]; } -} \ No newline at end of file +} + +void nested_array_designators() { + int x[1][2] = {[0][0] = 1234, [0][1] = 5678}; +} diff --git a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency.expected b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency.expected index 79887fffc1f..dca4c18ad29 100644 --- a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency.expected +++ b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency.expected @@ -7,6 +7,9 @@ duplicateChiOperand sideEffectWithoutPrimary instructionWithoutSuccessor ambiguousSuccessors +| ssa.c:3:14:3:16 | Uninitialized: definition of foo | Instruction 'Uninitialized: definition of foo' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:2:6:2:22 | void named_designators() | void named_designators() | +| ssa.c:7:13:7:37 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:6:6:6:25 | void repeated_designators() | void repeated_designators() | +| ssa.cpp:418:16:418:46 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.cpp:417:6:417:29 | void nested_array_designators() | void nested_array_designators() | unexplainedLoop unnecessaryPhiInstruction memoryOperandDefinitionIsUnmodeled diff --git a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency_unsound.expected b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency_unsound.expected index 79887fffc1f..dca4c18ad29 100644 --- a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency_unsound.expected +++ b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_consistency_unsound.expected @@ -7,6 +7,9 @@ duplicateChiOperand sideEffectWithoutPrimary instructionWithoutSuccessor ambiguousSuccessors +| ssa.c:3:14:3:16 | Uninitialized: definition of foo | Instruction 'Uninitialized: definition of foo' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:2:6:2:22 | void named_designators() | void named_designators() | +| ssa.c:7:13:7:37 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.c:6:6:6:25 | void repeated_designators() | void repeated_designators() | +| ssa.cpp:418:16:418:46 | PointerAdd: {...} | Instruction 'PointerAdd: {...}' has 2 successors of kind 'Goto' in function '$@'. | ssa.cpp:417:6:417:29 | void nested_array_designators() | void nested_array_designators() | unexplainedLoop unnecessaryPhiInstruction memoryOperandDefinitionIsUnmodeled diff --git a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected index 03de47a1ab0..d4c30812cc7 100644 --- a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected +++ b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected @@ -1,3 +1,72 @@ +ssa.c: +# 2| void named_designators() +# 2| Block 0 +# 2| v2_1(void) = EnterFunction : +# 2| mu2_2(unknown) = AliasedDefinition : +# 2| mu2_3(unknown) = InitializeNonLocal : +# 3| r3_1(glval) = VariableAddress[foo] : +# 3| mu3_2(Foo) = Uninitialized[foo] : &:r3_1 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[1234] : +# 3| mu3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| r3_13(int) = Constant[1] : +# 3| r3_15(glval) = PointerAdd[4] : r3_3, r3_13 +# 3| r3_17(int) = Constant[0] : +# 3| mu3_19(int) = Store[?] : &:r3_15, r3_17 +#-----| Goto -> Block 3 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[0] : +# 3| mu3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| r3_13(int) = Constant[1] : +# 3| r3_15(glval) = PointerAdd[4] : r3_3, r3_13 +# 3| r3_17(int) = Constant[5678] : +# 3| mu3_19(int) = Store[?] : &:r3_15, r3_17 +#-----| Goto -> Block 3 + +# 4| Block 3 +# 4| v4_1(void) = NoOp : +# 2| v2_4(void) = ReturnVoid : +# 2| v2_5(void) = AliasedUse : ~m? +# 2| v2_6(void) = ExitFunction : + +# 6| void repeated_designators() +# 6| Block 0 +# 6| v6_1(void) = EnterFunction : +# 6| mu6_2(unknown) = AliasedDefinition : +# 6| mu6_3(unknown) = InitializeNonLocal : +# 7| r7_1(glval) = VariableAddress[x] : +# 7| mu7_2(int[1]) = Uninitialized[x] : &:r7_1 +# 7| r7_3(int) = Constant[0] : +# 7| r7_4(glval) = PointerAdd[4] : r7_1, r7_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 7| Block 1 +# 7| r7_5(int) = Constant[1234] : +# 7| mu7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 7| Block 1 +# 7| r7_5(int) = Constant[5678] : +# 7| mu7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 8| Block 3 +# 8| v8_1(void) = NoOp : +# 6| v6_4(void) = ReturnVoid : +# 6| v6_5(void) = AliasedUse : ~m? +# 6| v6_6(void) = ExitFunction : + ssa.cpp: # 13| int ChiPhiNode(Point*, bool, bool) # 13| Block 0 @@ -1768,3 +1837,43 @@ ssa.cpp: # 401| v401_12(void) = ReturnVoid : # 401| v401_13(void) = AliasedUse : ~m? # 401| v401_14(void) = ExitFunction : + +# 417| void nested_array_designators() +# 417| Block 0 +# 417| v417_1(void) = EnterFunction : +# 417| mu417_2(unknown) = AliasedDefinition : +# 417| mu417_3(unknown) = InitializeNonLocal : +# 418| r418_1(glval) = VariableAddress[x] : +# 418| mu418_2(int[1][2]) = Uninitialized[x] : &:r418_1 +# 418| r418_3(int) = Constant[0] : +# 418| r418_4(glval) = PointerAdd[8] : r418_1, r418_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[0] : +# 418| mu418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| r418_13(int) = Constant[1] : +# 418| r418_15(glval) = PointerAdd[4] : r418_4, r418_13 +# 418| r418_17(int) = Constant[5678] : +# 418| mu418_19(int) = Store[?] : &:r418_15, r418_17 +#-----| Goto -> Block 3 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[1234] : +# 418| mu418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| r418_13(int) = Constant[1] : +# 418| r418_15(glval) = PointerAdd[4] : r418_4, r418_13 +# 418| r418_17(int) = Constant[0] : +# 418| mu418_19(int) = Store[?] : &:r418_15, r418_17 +#-----| Goto -> Block 3 + +# 419| Block 3 +# 419| v419_1(void) = NoOp : +# 417| v417_4(void) = ReturnVoid : +# 417| v417_5(void) = AliasedUse : ~m? +# 417| v417_6(void) = ExitFunction : diff --git a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir_unsound.expected b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir_unsound.expected index 03de47a1ab0..d4c30812cc7 100644 --- a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir_unsound.expected +++ b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir_unsound.expected @@ -1,3 +1,72 @@ +ssa.c: +# 2| void named_designators() +# 2| Block 0 +# 2| v2_1(void) = EnterFunction : +# 2| mu2_2(unknown) = AliasedDefinition : +# 2| mu2_3(unknown) = InitializeNonLocal : +# 3| r3_1(glval) = VariableAddress[foo] : +# 3| mu3_2(Foo) = Uninitialized[foo] : &:r3_1 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[1234] : +# 3| mu3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| r3_13(int) = Constant[1] : +# 3| r3_15(glval) = PointerAdd[4] : r3_3, r3_13 +# 3| r3_17(int) = Constant[0] : +# 3| mu3_19(int) = Store[?] : &:r3_15, r3_17 +#-----| Goto -> Block 3 + +# 3| Block 1 +# 3| r3_3(glval) = FieldAddress[x] : r3_1 +# 3| r3_5(int) = Constant[0] : +# 3| r3_7(glval) = PointerAdd[4] : r3_3, r3_5 +# 3| r3_9(int) = Constant[0] : +# 3| mu3_11(int) = Store[?] : &:r3_7, r3_9 +# 3| r3_13(int) = Constant[1] : +# 3| r3_15(glval) = PointerAdd[4] : r3_3, r3_13 +# 3| r3_17(int) = Constant[5678] : +# 3| mu3_19(int) = Store[?] : &:r3_15, r3_17 +#-----| Goto -> Block 3 + +# 4| Block 3 +# 4| v4_1(void) = NoOp : +# 2| v2_4(void) = ReturnVoid : +# 2| v2_5(void) = AliasedUse : ~m? +# 2| v2_6(void) = ExitFunction : + +# 6| void repeated_designators() +# 6| Block 0 +# 6| v6_1(void) = EnterFunction : +# 6| mu6_2(unknown) = AliasedDefinition : +# 6| mu6_3(unknown) = InitializeNonLocal : +# 7| r7_1(glval) = VariableAddress[x] : +# 7| mu7_2(int[1]) = Uninitialized[x] : &:r7_1 +# 7| r7_3(int) = Constant[0] : +# 7| r7_4(glval) = PointerAdd[4] : r7_1, r7_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 7| Block 1 +# 7| r7_5(int) = Constant[1234] : +# 7| mu7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 7| Block 1 +# 7| r7_5(int) = Constant[5678] : +# 7| mu7_7(int) = Store[?] : &:r7_4, r7_5 +#-----| Goto -> Block 3 + +# 8| Block 3 +# 8| v8_1(void) = NoOp : +# 6| v6_4(void) = ReturnVoid : +# 6| v6_5(void) = AliasedUse : ~m? +# 6| v6_6(void) = ExitFunction : + ssa.cpp: # 13| int ChiPhiNode(Point*, bool, bool) # 13| Block 0 @@ -1768,3 +1837,43 @@ ssa.cpp: # 401| v401_12(void) = ReturnVoid : # 401| v401_13(void) = AliasedUse : ~m? # 401| v401_14(void) = ExitFunction : + +# 417| void nested_array_designators() +# 417| Block 0 +# 417| v417_1(void) = EnterFunction : +# 417| mu417_2(unknown) = AliasedDefinition : +# 417| mu417_3(unknown) = InitializeNonLocal : +# 418| r418_1(glval) = VariableAddress[x] : +# 418| mu418_2(int[1][2]) = Uninitialized[x] : &:r418_1 +# 418| r418_3(int) = Constant[0] : +# 418| r418_4(glval) = PointerAdd[8] : r418_1, r418_3 +#-----| Goto -> Block 1 +#-----| Goto -> Block 1 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[0] : +# 418| mu418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| r418_13(int) = Constant[1] : +# 418| r418_15(glval) = PointerAdd[4] : r418_4, r418_13 +# 418| r418_17(int) = Constant[5678] : +# 418| mu418_19(int) = Store[?] : &:r418_15, r418_17 +#-----| Goto -> Block 3 + +# 418| Block 1 +# 418| r418_5(int) = Constant[0] : +# 418| r418_7(glval) = PointerAdd[4] : r418_4, r418_5 +# 418| r418_9(int) = Constant[1234] : +# 418| mu418_11(int) = Store[?] : &:r418_7, r418_9 +# 418| r418_13(int) = Constant[1] : +# 418| r418_15(glval) = PointerAdd[4] : r418_4, r418_13 +# 418| r418_17(int) = Constant[0] : +# 418| mu418_19(int) = Store[?] : &:r418_15, r418_17 +#-----| Goto -> Block 3 + +# 419| Block 3 +# 419| v419_1(void) = NoOp : +# 417| v417_4(void) = ReturnVoid : +# 417| v417_5(void) = AliasedUse : ~m? +# 417| v417_6(void) = ExitFunction :