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,13 +267,15 @@ 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) 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; 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->mType = EX_CONSTANT;
exp->mDecValue = cexp->mDecValue; exp->mDecValue = cexp->mDecValue;
}
changed = true; changed = true;
} }
}
if (ReplaceGlobalConst(exp->mLeft)) if (ReplaceGlobalConst(exp->mLeft))
changed = true; changed = true;

View File

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