mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ownership] Define a new instruction copy_unmanaged_value.
This provides a singular instruction for convert an unmanaged value to a ref, then strong_retain it. I expanded the definition of UNCHECKED_REF_STORAGE to include these copy like instructions. This instruction is valid in all SIL. The reason why I am adding this instruction is that currently when we emit an access to an unowned (unsafe) ivar, we use an unmanaged_to_ref and a strong retain. This can look to the optimizer like a strong retain that can potentially be optimized. By combining the two together into a new instruction, we can avoid this potential problem since the pattern matching will break.
This commit is contained in:
@@ -154,6 +154,9 @@ public:
|
||||
}
|
||||
REFCOUNTINC_MEMBEHAVIOR_INST(StrongRetainInst)
|
||||
REFCOUNTINC_MEMBEHAVIOR_INST(RetainValueInst)
|
||||
#define UNCHECKED_REF_STORAGE(Name, ...) \
|
||||
REFCOUNTINC_MEMBEHAVIOR_INST(Name##RetainValueInst) \
|
||||
REFCOUNTINC_MEMBEHAVIOR_INST(Copy##Name##ValueInst)
|
||||
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
|
||||
REFCOUNTINC_MEMBEHAVIOR_INST(Name##RetainInst) \
|
||||
REFCOUNTINC_MEMBEHAVIOR_INST(StrongRetain##Name##Inst) \
|
||||
|
||||
Reference in New Issue
Block a user