Skip to content

Commit 90dc14c

Browse files
author
Dave Bartolomeo
committed
C++/C#: Fix phantom Chi definitions in PrintSSA
When `PrintSSA.qll` is imported, IR dumps will be annotated with the alias analysis information used during SSA construction. When printing this information, we incorrectly treated instructions at offset -1, which should only be `Phi` instructions, as `Chi` instructions for the instruction at offset 0. This produced phantom annotations, but did not affect the correctness of the actual IR.
1 parent 0d86866 commit 90dc14c

File tree

3 files changed

+6
-3
lines changed
  • cpp/ql/src/semmle/code/cpp/ir/implementation
  • csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal

3 files changed

+6
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ private import DebugSSA
66

77
bindingset[offset]
88
private string getKeySuffixForOffset(int offset) {
9+
offset >= 0 and
910
if offset % 2 = 0 then result = "" else result = "_Chi"
1011
}
1112

1213
bindingset[offset]
13-
private int getIndexForOffset(int offset) { result = offset / 2 }
14+
private int getIndexForOffset(int offset) { offset >= 0 and result = offset / 2 }
1415

1516
/**
1617
* Property provide that dumps the memory access of each result. Useful for debugging SSA

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ private import DebugSSA
66

77
bindingset[offset]
88
private string getKeySuffixForOffset(int offset) {
9+
offset >= 0 and
910
if offset % 2 = 0 then result = "" else result = "_Chi"
1011
}
1112

1213
bindingset[offset]
13-
private int getIndexForOffset(int offset) { result = offset / 2 }
14+
private int getIndexForOffset(int offset) { offset >= 0 and result = offset / 2 }
1415

1516
/**
1617
* Property provide that dumps the memory access of each result. Useful for debugging SSA

csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ private import DebugSSA
66

77
bindingset[offset]
88
private string getKeySuffixForOffset(int offset) {
9+
offset >= 0 and
910
if offset % 2 = 0 then result = "" else result = "_Chi"
1011
}
1112

1213
bindingset[offset]
13-
private int getIndexForOffset(int offset) { result = offset / 2 }
14+
private int getIndexForOffset(int offset) { offset >= 0 and result = offset / 2 }
1415

1516
/**
1617
* Property provide that dumps the memory access of each result. Useful for debugging SSA

0 commit comments

Comments
 (0)