Fix array to pointer cast
This commit is contained in:
parent
d8ecd34ac6
commit
480270f4c9
|
@ -1851,6 +1851,7 @@ InterCodeBasicBlock::InterCodeBasicBlock(void)
|
|||
mInPath = false;
|
||||
mLoopHead = false;
|
||||
mChecked = false;
|
||||
mTraceIndex = -1;
|
||||
}
|
||||
|
||||
InterCodeBasicBlock::~InterCodeBasicBlock(void)
|
||||
|
@ -1924,15 +1925,17 @@ void InterCodeBasicBlock::GenerateTraces(bool expand)
|
|||
|
||||
for (;;)
|
||||
{
|
||||
if (mTrueJump && mTrueJump->mInstructions.Size() == 1 && mTrueJump->mInstructions[0]->mCode == IC_JUMP && !mTrueJump->mLoopHead)
|
||||
if (mTrueJump && mTrueJump->mInstructions.Size() == 1 && mTrueJump->mInstructions[0]->mCode == IC_JUMP && !mTrueJump->mLoopHead && mTrueJump->mTraceIndex != mIndex)
|
||||
{
|
||||
mTrueJump->mTraceIndex = mIndex;
|
||||
mTrueJump->mNumEntries--;
|
||||
mTrueJump = mTrueJump->mTrueJump;
|
||||
if (mTrueJump)
|
||||
mTrueJump->mNumEntries++;
|
||||
}
|
||||
else if (mFalseJump && mFalseJump->mInstructions.Size() == 1 && mFalseJump->mInstructions[0]->mCode == IC_JUMP && !mFalseJump->mLoopHead)
|
||||
else if (mFalseJump && mFalseJump->mInstructions.Size() == 1 && mFalseJump->mInstructions[0]->mCode == IC_JUMP && !mFalseJump->mLoopHead && mFalseJump->mTraceIndex != mIndex)
|
||||
{
|
||||
mFalseJump->mTraceIndex = mIndex;
|
||||
mFalseJump->mNumEntries--;
|
||||
mFalseJump = mFalseJump->mTrueJump;
|
||||
if (mFalseJump)
|
||||
|
|
|
@ -404,7 +404,7 @@ public:
|
|||
class InterCodeBasicBlock
|
||||
{
|
||||
public:
|
||||
int mIndex, mNumEntries, mNumEntered;
|
||||
int mIndex, mNumEntries, mNumEntered, mTraceIndex;
|
||||
InterCodeBasicBlock * mTrueJump, * mFalseJump, * mDominator;
|
||||
GrowingInstructionArray mInstructions;
|
||||
|
||||
|
|
|
@ -2706,6 +2706,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
// no need for actual operation when casting pointer to pointer
|
||||
return ExValue(exp->mLeft->mDecType, vr.mTemp, vr.mReference);
|
||||
}
|
||||
else if (exp->mLeft->mDecType->mType == DT_TYPE_POINTER && vr.mType->mType == DT_TYPE_ARRAY)
|
||||
{
|
||||
// no need for actual operation when casting pointer to pointer
|
||||
return ExValue(exp->mLeft->mDecType, vr.mTemp, vr.mReference - 1);
|
||||
}
|
||||
else if (exp->mLeft->mDecType->mType != DT_TYPE_VOID && vr.mType->mType == DT_TYPE_VOID)
|
||||
{
|
||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Cannot cast void object to non void object");
|
||||
|
|
|
@ -7956,9 +7956,9 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
|||
int apos, breg, ireg;
|
||||
if (FindAddressSumY(i, sreg, apos, breg, ireg))
|
||||
{
|
||||
if (breg != mIns[i + 0].mAddress || !(mIns[i + 0].mLive & LIVE_MEM))
|
||||
if (!(breg == sreg || ireg == sreg)|| !(mIns[i + 0].mLive & LIVE_MEM))
|
||||
{
|
||||
if (breg == mIns[i + 0].mAddress)
|
||||
if (breg == sreg || ireg == sreg)
|
||||
{
|
||||
mIns[apos + 3].mType = ASMIT_NOP;
|
||||
mIns[apos + 3].mMode = ASMIM_IMPLIED;
|
||||
|
|
Loading…
Reference in New Issue