Keep unused variable stores if optimization is turned off
This commit is contained in:
parent
d047152646
commit
30b3ed610e
|
@ -4,6 +4,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
static bool CheckFunc;
|
||||||
|
|
||||||
int InterTypeSize[] = {
|
int InterTypeSize[] = {
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
@ -14906,64 +14908,67 @@ void InterCodeProcedure::RemoveUnusedInstructions(void)
|
||||||
|
|
||||||
void InterCodeProcedure::RemoveUnusedStoreInstructions(InterMemory paramMemory)
|
void InterCodeProcedure::RemoveUnusedStoreInstructions(InterMemory paramMemory)
|
||||||
{
|
{
|
||||||
if (mLocalVars.Size() > 0 || mParamVars.Size() > 0)
|
if (mCompilerOptions & COPT_OPTIMIZE_BASIC)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mLocalAliasedSet.Size(); i++)
|
if (mLocalVars.Size() > 0 || mParamVars.Size() > 0)
|
||||||
{
|
{
|
||||||
if (mLocalAliasedSet[i])
|
for (int i = 0; i < mLocalAliasedSet.Size(); i++)
|
||||||
mLocalVars[i]->mAliased = true;
|
{
|
||||||
}
|
if (mLocalAliasedSet[i])
|
||||||
for (int i = 0; i < mParamAliasedSet.Size(); i++)
|
mLocalVars[i]->mAliased = true;
|
||||||
{
|
}
|
||||||
if (mParamAliasedSet[i])
|
for (int i = 0; i < mParamAliasedSet.Size(); i++)
|
||||||
mParamVars[i]->mAliased = true;
|
{
|
||||||
}
|
if (mParamAliasedSet[i])
|
||||||
|
mParamVars[i]->mAliased = true;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now remove unused stores
|
// Now remove unused stores
|
||||||
//
|
//
|
||||||
|
|
||||||
do {
|
|
||||||
ResetVisited();
|
|
||||||
mEntryBlock->BuildLocalVariableSets(mLocalVars, mParamVars, paramMemory);
|
|
||||||
|
|
||||||
ResetVisited();
|
|
||||||
mEntryBlock->BuildGlobalProvidedVariableSet(mLocalVars, NumberSet(mLocalVars.Size()), mParamVars, NumberSet(mParamVars.Size()), paramMemory);
|
|
||||||
|
|
||||||
NumberSet totalRequired2(mLocalVars.Size());
|
|
||||||
NumberSet totalRequiredParams(mParamVars.Size());
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
} while (mEntryBlock->BuildGlobalRequiredVariableSet(mLocalVars, totalRequired2, mParamVars, totalRequiredParams, paramMemory));
|
mEntryBlock->BuildLocalVariableSets(mLocalVars, mParamVars, paramMemory);
|
||||||
|
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
} while (mEntryBlock->RemoveUnusedStoreInstructions(mLocalVars, mParamVars, paramMemory));
|
mEntryBlock->BuildGlobalProvidedVariableSet(mLocalVars, NumberSet(mLocalVars.Size()), mParamVars, NumberSet(mParamVars.Size()), paramMemory);
|
||||||
|
|
||||||
DisassembleDebug("removed unused local stores");
|
NumberSet totalRequired2(mLocalVars.Size());
|
||||||
}
|
NumberSet totalRequiredParams(mParamVars.Size());
|
||||||
|
|
||||||
// Remove unused global stores
|
do {
|
||||||
|
ResetVisited();
|
||||||
|
} while (mEntryBlock->BuildGlobalRequiredVariableSet(mLocalVars, totalRequired2, mParamVars, totalRequiredParams, paramMemory));
|
||||||
|
|
||||||
if (mModule->mGlobalVars.Size())
|
ResetVisited();
|
||||||
{
|
} while (mEntryBlock->RemoveUnusedStoreInstructions(mLocalVars, mParamVars, paramMemory));
|
||||||
do {
|
|
||||||
ResetVisited();
|
|
||||||
mEntryBlock->BuildStaticVariableSet(mModule->mGlobalVars);
|
|
||||||
|
|
||||||
ResetVisited();
|
DisassembleDebug("removed unused local stores");
|
||||||
mEntryBlock->BuildGlobalProvidedStaticVariableSet(mModule->mGlobalVars, NumberSet(mModule->mGlobalVars.Size()));
|
}
|
||||||
|
|
||||||
NumberSet totalRequired2(mModule->mGlobalVars.Size());
|
// Remove unused global stores
|
||||||
|
|
||||||
|
if (mModule->mGlobalVars.Size())
|
||||||
|
{
|
||||||
do {
|
do {
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
} while (mEntryBlock->BuildGlobalRequiredStaticVariableSet(mModule->mGlobalVars, totalRequired2));
|
mEntryBlock->BuildStaticVariableSet(mModule->mGlobalVars);
|
||||||
|
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
} while (mEntryBlock->RemoveUnusedStaticStoreInstructions(mModule->mGlobalVars));
|
mEntryBlock->BuildGlobalProvidedStaticVariableSet(mModule->mGlobalVars, NumberSet(mModule->mGlobalVars.Size()));
|
||||||
|
|
||||||
DisassembleDebug("removed unused static stores");
|
NumberSet totalRequired2(mModule->mGlobalVars.Size());
|
||||||
|
|
||||||
|
do {
|
||||||
|
ResetVisited();
|
||||||
|
} while (mEntryBlock->BuildGlobalRequiredStaticVariableSet(mModule->mGlobalVars, totalRequired2));
|
||||||
|
|
||||||
|
ResetVisited();
|
||||||
|
} while (mEntryBlock->RemoveUnusedStaticStoreInstructions(mModule->mGlobalVars));
|
||||||
|
|
||||||
|
DisassembleDebug("removed unused static stores");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15336,6 +15341,8 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
|
// CheckFunc = !strcmp(mIdent->mString, "joy_poll");
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
||||||
DisassembleDebug("start");
|
DisassembleDebug("start");
|
||||||
|
@ -16158,9 +16165,12 @@ void InterCodeProcedure::MarkRelevantStatics(void)
|
||||||
|
|
||||||
void InterCodeProcedure::RemoveNonRelevantStatics(void)
|
void InterCodeProcedure::RemoveNonRelevantStatics(void)
|
||||||
{
|
{
|
||||||
ResetVisited();
|
if (mCompilerOptions & COPT_OPTIMIZE_BASIC)
|
||||||
mEntryBlock->RemoveNonRelevantStatics();
|
{
|
||||||
RemoveUnusedInstructions();
|
ResetVisited();
|
||||||
|
mEntryBlock->RemoveNonRelevantStatics();
|
||||||
|
RemoveUnusedInstructions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterCodeProcedure::MapVariables(void)
|
void InterCodeProcedure::MapVariables(void)
|
||||||
|
@ -16647,6 +16657,9 @@ void InterCodeProcedure::Disassemble(const char* name, bool dumpSets)
|
||||||
FILE* file;
|
FILE* file;
|
||||||
static bool initial = true;
|
static bool initial = true;
|
||||||
|
|
||||||
|
if (!CheckFunc)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!initial)
|
if (!initial)
|
||||||
{
|
{
|
||||||
fopen_s(&file, "r:\\cldiss.txt", "a");
|
fopen_s(&file, "r:\\cldiss.txt", "a");
|
||||||
|
|
Loading…
Reference in New Issue