[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:
Michael Gottesman
2019-08-25 17:01:44 -07:00
parent 0c0a9844b7
commit 5fc1d1d349
31 changed files with 223 additions and 107 deletions

View File

@@ -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) \