Continued from D13603...
When generating invariant_start intrinsic calls for any given (instantiated) object, instead of simply recording information about whether the object is 'const', record the offsets of sub-fields of the objects that are 'const'. This turns the definition of the invariant_start instruction into a variadic function of at least two arguments, where the first two arguments are information about the allocated memory.
If the invariant_start call instruction only has two arguments, then the object is 'writeonce'. Otherwise, it is not 'writeonce' but has 'writeonce' sub-fields at the indicated offsets.
Instead of tracking a separate Computed flag, use InvariantOffsets.count(Record) here, and insert the value below.