mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
Split the `Assign` partition operation into `AssignDirect` and `AssignIndirect` to properly handle the case where a value in memory is overwritten. Previously, when a store instruction overwrote a value in memory (e.g., `store %new to [assign] %addr`), we would simply update %addr's region to match %new's region. This caused us to lose information about the original value that was in %addr, which could include actor or task isolation info. For example: %addr = alloc_stack store %task_local to [init] %addr // %addr's region is task-isolated store %new_value to [assign] %addr // Previously: lost task isolation! Now, `AssignIndirect` creates a new representative value (identified by the store's destination operand) for the overwritten value and merges it into the destination's region before reassigning. This preserves the region's isolation properties. `AssignDirect` continues to be used for direct results where the SSA value itself is new (e.g., struct_extract results, pack_element_get addresses). The actual implementation change for AssignIndirect will come in a follow-up commit. This commit only refactors code in preparation for that.