swift
719ee256 - [constant-folding] When simplifying destructures, do not handle cases where we have a non-trivial value with .none ownership.

Commit
6 years ago
[constant-folding] When simplifying destructures, do not handle cases where we have a non-trivial value with .none ownership. In certain cases, in OSSA, non-trivial values with .none ownership can be merged into .owned aggregates such that when we extract the value back out from the aggregate we lost the information that the original value was not .owned. As an example of this consider the following SIL: bb0(%0 : @owned Builtin.NativeObject): %1 = enum $Optional<Builtin.NativeObject>, #Optional.none!enumelt %2 = tuple(%0 : $Builtin.NativeObject, %1 : $Optional<Builtin.NativeObject>) (%3, %4) = destructure_tuple %2 : $(Builtin.NativeObject, Optional<Builtin.NativeObject>) In this case, %4 has .owned ownership, while %1 has .none ownership. This is because we have lost the refined information that we originally had a .none value as input to the tuple we are destructuring. Due to this when we RAUW, we would need to insert a destroy on %4 to make sure that we maintain ossa invariants. This is safe since the destroy_value will be on a dynamically .none value, which is a no-op. That being said, the intention here was actually not to implement this pattern in the code (as can be seen by not handling @owned destructures). Thus this commit just makes the constant folding code more conservative to ensure that we do not try to handle this case.
Author
Committer
Parents
Loading