This serves two purposes:
- Because, today, we only copy the StructValue, modifying the destination of the copy also modifies the source. This is demonstrated by the new checks added to CopyConstructor and MoveConstructor, which fail without the deep copy.
- It lays the groundwork for eliminating the redundancy between AggregateStorageLocation and StructValue, which will happen as part of the ongoing migration to strict handling of value categories (seeo https://discourse.llvm.org/t/70086 for details). This will involve turning StructValue into essentially just a wrapper for AggregateStorageLocation; under this scheme, the current "shallow" copy (copying a StructValue from one AggregateStorageLocation to another) will no longer be possible.
Because we now perform deep copies, tests need to perform a deep equality
comparison instead of just comparing for equal identity of the StructValues.
The new function recordsEqual() provides such a deep equality comparison.
Shouldn't it go the other way, from Src to Dst?