| 13808 | } |
| 13809 | |
| 13810 | BfTypedValue BfModule::MakeAddressable(BfTypedValue typedVal, bool forceMutable, bool forceAddressable) |
| 13811 | { |
| 13812 | if (!typedVal) |
| 13813 | return typedVal; |
| 13814 | |
| 13815 | bool wasReadOnly = typedVal.IsReadOnly(); |
| 13816 | |
| 13817 | if ((forceAddressable) || |
| 13818 | ((typedVal.mType->IsValueType()) && |
| 13819 | (!typedVal.mType->IsValuelessNonOpaqueType()))) |
| 13820 | { |
| 13821 | wasReadOnly = true; // Any non-addr is implicitly read-only |
| 13822 | |
| 13823 | //static int gCallIdx = 0; |
| 13824 | FixValueActualization(typedVal); |
| 13825 | if (typedVal.IsAddr()) |
| 13826 | return typedVal; |
| 13827 | BfType* type = typedVal.mType; |
| 13828 | PopulateType(type); |
| 13829 | BfIRValue tempVar; |
| 13830 | if (typedVal.mValue.IsFake()) |
| 13831 | tempVar = mBfIRBuilder->GetFakeVal(); |
| 13832 | else |
| 13833 | { |
| 13834 | tempVar = CreateAlloca(type); |
| 13835 | if (typedVal.IsSplat()) |
| 13836 | AggregateSplatIntoAddr(typedVal, tempVar); |
| 13837 | else |
| 13838 | mBfIRBuilder->CreateAlignedStore(typedVal.mValue, tempVar, type->mAlign); |
| 13839 | } |
| 13840 | |
| 13841 | if (forceMutable) |
| 13842 | wasReadOnly = false; |
| 13843 | |
| 13844 | return BfTypedValue(tempVar, type, |
| 13845 | typedVal.IsThis() ? |
| 13846 | (wasReadOnly ? BfTypedValueKind_ReadOnlyThisAddr : BfTypedValueKind_ThisAddr) : |
| 13847 | (wasReadOnly ? BfTypedValueKind_ReadOnlyAddr : BfTypedValueKind_Addr)); |
| 13848 | } |
| 13849 | return LoadValue(typedVal); |
| 13850 | } |
| 13851 | |
| 13852 | BfTypedValue BfModule::RemoveReadOnly(BfTypedValue typedValue) |
| 13853 | { |
no test coverage detected