Files
codeql/cpp/ql/test/library-tests/ir/ir/perf-regression.cpp
Jonas Jensen d378da33e8 C++ IR: Fix performance of large array value init
There were two problems here.

1. The inline predicates `isInitialized` and `isValueInitialized` on
   `ArrayAggregateLiteral` caused their callers to materialize every
   `int` that was a valid index into the array. This was slow on huge
   value-initialized arrays.
2. The `isInitialized` predicate was used in the `TInstructionTag` IPA
   type, creating a numbered tuple for each integer in it. This seemed
   to be entirely unnecessary since the `TranslatedElement`s using those
   tags were already indexed appropriately.
2019-08-06 14:50:57 +02:00

14 lines
281 B
C++

// This test ensures that we can efficiently generate IR for a large
// value-initialized array.
struct Big {
char buffer[1 << 30]; // 1 GiB
Big() : buffer() {} // This explicit init of `buffer` makes it value-initialized
};
int main() {
Big *big = new Big;
return 0;
}