Skip to content

Commit cf1bc69

Browse files
committed
C++: Fix coversEntireVariable perf in AliasedSSA
This predicate got an unfortunate join order, leading to these tuple counts on ElektraInitiative/libelektra: (290s) Tuple counts for AliasedSSA::VariableMemoryLocation::coversEntireVariable_dispred#f: 57117 ~0% {3} r1 = SCAN IRType::IRType::getByteSize_dispred#ff AS I OUTPUT 0, (I.<1> * 8), I.<0> 421445272 ~0% {3} r2 = JOIN r1 WITH AliasedSSA::VariableMemoryLocation#fffffff_5601#join_rhs AS R ON FIRST 2 OUTPUT R.<3>, r1.<2>, R.<2> 103282 ~2% {1} r3 = JOIN r2 WITH AliasConfiguration::Allocation::getIRType_dispred#ff AS R ON FIRST 2 OUTPUT r2.<2> return r3 With this commit, we get these tuple counts instead: (0s) Tuple counts for AliasedSSA::VariableMemoryLocation::varIRTypeHasBitRange#bff: 361874 ~0% {3} r1 = SCAN AliasedSSA::VariableMemoryLocation#fffffff AS I OUTPUT I.<1>, 0, I.<0> 361874 ~0% {3} r2 = JOIN r1 WITH AliasConfiguration::Allocation::getIRType_dispred#ff AS R ON FIRST 1 OUTPUT R.<1>, 0, r1.<2> 361874 ~1% {3} r3 = JOIN r2 WITH IRType::IRType::getByteSize_dispred#ff AS R ON FIRST 1 OUTPUT r2.<2>, 0, (R.<1> * 8) return r3 (0s) Tuple counts for AliasedSSA::VariableMemoryLocation::coversEntireVariable_dispred#f: 103282 ~2% {1} r1 = JOIN AliasedSSA::VariableMemoryLocation#fffffff_056#join_rhs AS L WITH AliasedSSA::VariableMemoryLocation::varIRTypeHasBitRange#bff AS R ON FIRST 3 OUTPUT L.<0> 103282 ~2% {1} r2 = STREAM DEDUP r1 return r2
1 parent 09960e0 commit cf1bc69

File tree

1 file changed

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

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,12 @@ class VariableMemoryLocation extends TVariableMemoryLocation, AllocationMemoryLo
220220
/**
221221
* Holds if this memory location covers the entire variable.
222222
*/
223-
final predicate coversEntireVariable() {
224-
startBitOffset = 0 and
225-
endBitOffset = var.getIRType().getByteSize() * 8
223+
final predicate coversEntireVariable() { varIRTypeHasBitRange(startBitOffset, endBitOffset) }
224+
225+
pragma[noinline]
226+
private predicate varIRTypeHasBitRange(int start, int end) {
227+
start = 0 and
228+
end = var.getIRType().getByteSize() * 8
226229
}
227230
}
228231

0 commit comments

Comments
 (0)