1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 12:02:21 +02:00

Fixed duplicate global variables when used as default args

This commit is contained in:
Brian Fiete 2021-02-11 06:48:51 -08:00
parent 503590cea5
commit fb0bace727
4 changed files with 73 additions and 60 deletions

View file

@ -13722,6 +13722,10 @@ BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
{
globalValue = *globalValuePtr;
BF_ASSERT(globalValue);
auto globalVar = (BfGlobalVar*)mBfIRBuilder->GetConstant(globalValue);
if ((globalVar->mStreamId == -1) && (!mBfIRBuilder->mIgnoreWrites))
mBfIRBuilder->CreateGlobalVariable(globalValue);
}
else
{
@ -13753,16 +13757,11 @@ BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
BfIRValue(),
staticVarName,
IsThreadLocal(fieldInstance));
if (!mBfIRBuilder->mIgnoreWrites)
{
// Only store this if we actually did the creation
BF_ASSERT(globalValue);
mStaticFieldRefs[fieldInstance] = globalValue;
}
BF_ASSERT(globalValue);
mStaticFieldRefs[fieldInstance] = globalValue;
BfLogSysM("Mod:%p Type:%p ReferenceStaticField %p -> %p\n", this, fieldInstance->mOwner, fieldInstance, globalValue);
}
}