[clang] [clang][bytecode] Add lifetime information for primitive array elements (PR #173333)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 22 18:47:38 PST 2026
================
@@ -29,3 +26,29 @@ bool InitMap::isElementInitialized(unsigned I) const {
unsigned Bucket = I / PER_FIELD;
return data()[Bucket] & (T(1) << (I % PER_FIELD));
}
+
+// Values in the second half of data() are inverted,
+// i.e. 0 means "lifetime started".
+void InitMap::startElementLifetime(unsigned I) {
+ unsigned LifetimeIndex = NumElems + I;
+
+ unsigned Bucket = numFields(NumElems) / 2 + (I / PER_FIELD);
----------------
shafik wrote:
You calculate Bucket and Mask in several place, this is problematic. Duplicates are known to drift over time and are a prime source for bugs.
More confusingly you seem to have two different calculation for Bucket, which is ripe for bugs when a future person comes and modifies the code and confuses the two.
https://github.com/llvm/llvm-project/pull/173333
More information about the cfe-commits
mailing list