Fix pointer to object size propagation

This commit is contained in:
drmortalwombat 2024-09-19 21:55:24 +02:00
parent 92b72b19ec
commit dfe233a95e
2 changed files with 6 additions and 9 deletions

View File

@ -267,12 +267,14 @@ bool GlobalOptimizer::ReplaceGlobalConst(Expression* exp)
if (exp->mType == EX_VARIABLE && (exp->mDecValue->mFlags & (DTF_GLOBAL | DTF_STATIC)) && !(exp->mDecValue->mOptFlags & (OPTF_VAR_MODIFIED | OPTF_VAR_ADDRESS)) && exp->mDecValue->mValue)
{
Expression* cexp = exp->mDecValue->mValue;
if (cexp->mType == EX_CONSTANT)
if (cexp->mType == EX_CONSTANT &&
(cexp->mDecValue->mType == DT_CONST_ADDRESS || cexp->mDecValue->mType == DT_CONST_INTEGER ||
cexp->mDecValue->mType == DT_CONST_POINTER || cexp->mDecValue->mType == DT_CONST_FLOAT))
{
exp->mType = EX_CONSTANT;
exp->mDecValue = cexp->mDecValue;
changed = true;
}
changed = true;
}
if (ReplaceGlobalConst(exp->mLeft))

View File

@ -4202,12 +4202,7 @@ bool InterInstruction::PropagateConstTemps(const GrowingInstructionPtrArray& cte
{
InterInstruction* ains = ctemps[mSrc[0].mTemp];
mCode = IC_CONSTANT;
mConst.mIntConst = ains->mConst.mIntConst;
mConst.mFloatConst = ains->mConst.mFloatConst;
mConst.mLinkerObject = ains->mConst.mLinkerObject;
mConst.mVarIndex = ains->mConst.mVarIndex;
mConst.mMemory = ains->mConst.mMemory;
mConst.mType = ains->mConst.mType;
mConst = ains->mConst;
mSrc[0].mTemp = -1;
mNumOperands = 0;
return true;
@ -22243,7 +22238,7 @@ void InterCodeProcedure::Close(void)
{
GrowingTypeArray tstack(IT_NONE);
CheckFunc = !strcmp(mIdent->mString, "main");
CheckFunc = !strcmp(mIdent->mString, "intro_display");
CheckCase = false;
mEntryBlock = mBlocks[0];