Fix drop of reading from volatile with discarding result
This commit is contained in:
parent
3c129ff4e5
commit
a6f9c733a1
|
@ -236,46 +236,40 @@ w0:
|
||||||
// Clear BSS Segment
|
// Clear BSS Segment
|
||||||
|
|
||||||
#ifndef NOBSSCLEAR
|
#ifndef NOBSSCLEAR
|
||||||
lda #<BSSStart
|
ldx #>BSSStart
|
||||||
sta ip
|
ldy #<BSSStart
|
||||||
lda #>BSSStart
|
|
||||||
sta ip + 1
|
|
||||||
|
|
||||||
sec
|
|
||||||
lda #>BSSEnd
|
|
||||||
sbc #>BSSStart
|
|
||||||
beq w1
|
|
||||||
tax
|
|
||||||
lda #0
|
lda #0
|
||||||
ldy #0
|
sta ip
|
||||||
l1: sta (ip), y
|
l3:
|
||||||
|
stx ip + 1
|
||||||
|
cpx #>BSSEnd
|
||||||
|
beq w2
|
||||||
|
l1:
|
||||||
|
sta (ip), y
|
||||||
iny
|
iny
|
||||||
bne l1
|
bne l1
|
||||||
inc ip + 1
|
|
||||||
dex
|
|
||||||
bne l1
|
|
||||||
w1:
|
|
||||||
sec
|
|
||||||
lda #<BSSEnd
|
|
||||||
sbc #<BSSStart
|
|
||||||
beq w2
|
|
||||||
tay
|
|
||||||
lda #0
|
|
||||||
l2: dey
|
|
||||||
sta (ip), y
|
|
||||||
bne l2
|
|
||||||
w2:
|
|
||||||
#endif
|
|
||||||
#ifndef NOZPCLEAR
|
|
||||||
ldx #<ZeroStart
|
|
||||||
cpx #<ZeroEnd
|
|
||||||
beq w3
|
|
||||||
l3: sta $00, x
|
|
||||||
inx
|
inx
|
||||||
cpx #<ZeroEnd
|
|
||||||
bne l3
|
bne l3
|
||||||
w3:
|
l2:
|
||||||
|
sta (ip), y
|
||||||
|
iny
|
||||||
|
w2:
|
||||||
|
cpy #<BSSEnd
|
||||||
|
bne l2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NOZPCLEAR
|
||||||
|
lda #0
|
||||||
|
ldx #<ZeroStart
|
||||||
|
bne w3
|
||||||
|
l4: sta $00, x
|
||||||
|
inx
|
||||||
|
w3:
|
||||||
|
cpx #<ZeroEnd
|
||||||
|
bne l4
|
||||||
|
#endif
|
||||||
|
|
||||||
lda #<StackEnd - 2
|
lda #<StackEnd - 2
|
||||||
sta sp
|
sta sp
|
||||||
lda #>StackEnd - 2
|
lda #>StackEnd - 2
|
||||||
|
|
|
@ -387,6 +387,17 @@ bool Expression::IsRValue(void) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Expression::IsVolatile(void) const
|
||||||
|
{
|
||||||
|
if (mDecType->mFlags & DTF_VOLATILE)
|
||||||
|
return true;
|
||||||
|
if (mLeft && mLeft->IsVolatile())
|
||||||
|
return true;
|
||||||
|
if (mRight && mRight->IsVolatile())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Expression::IsConstRef(void) const
|
bool Expression::IsConstRef(void) const
|
||||||
{
|
{
|
||||||
if (mDecType->mType == DT_TYPE_RVALUEREF || mDecType->mType == DT_TYPE_REFERENCE)
|
if (mDecType->mType == DT_TYPE_RVALUEREF || mDecType->mType == DT_TYPE_REFERENCE)
|
||||||
|
|
|
@ -126,6 +126,7 @@ static const uint64 DTF_VAR_ALIASING = (1ULL << 48);
|
||||||
static const uint64 DTF_FPARAM_UNUSED = (1ULL << 49);
|
static const uint64 DTF_FPARAM_UNUSED = (1ULL << 49);
|
||||||
static const uint64 DTF_DEPRECATED = (1ULL << 50);
|
static const uint64 DTF_DEPRECATED = (1ULL << 50);
|
||||||
static const uint64 DTF_FUNC_NO_RETURN = (1ULL << 51);
|
static const uint64 DTF_FUNC_NO_RETURN = (1ULL << 51);
|
||||||
|
static const uint64 DTF_PLACED = (1ULL << 52);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,6 +268,7 @@ public:
|
||||||
bool IsRValue(void) const;
|
bool IsRValue(void) const;
|
||||||
bool IsLValue(void) const;
|
bool IsLValue(void) const;
|
||||||
bool IsConstRef(void) const;
|
bool IsConstRef(void) const;
|
||||||
|
bool IsVolatile(void) const;
|
||||||
|
|
||||||
void Dump(int ident) const;
|
void Dump(int ident) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -189,7 +189,7 @@ bool GlobalOptimizer::CheckUnusedLocals(Expression*& exp)
|
||||||
if (vexp->mType == EX_VARIABLE)
|
if (vexp->mType == EX_VARIABLE)
|
||||||
{
|
{
|
||||||
Declaration* vdec = vexp->mDecValue;
|
Declaration* vdec = vexp->mDecValue;
|
||||||
if (vdec->mType == DT_VARIABLE && !(vdec->mFlags & (DTF_GLOBAL | DTF_STATIC)) && !(vdec->mOptFlags & OPTF_VAR_USED))
|
if (vdec->mType == DT_VARIABLE && !(vdec->mFlags & (DTF_GLOBAL | DTF_STATIC)) && !(vdec->mOptFlags & OPTF_VAR_USED) && !exp->mRight->IsVolatile())
|
||||||
{
|
{
|
||||||
exp = exp->mRight;
|
exp = exp->mRight;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -22913,7 +22913,7 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
CheckFunc = !strcmp(mIdent->mString, "__computeCharsetSrc__");
|
CheckFunc = !strcmp(mIdent->mString, "main");
|
||||||
CheckCase = false;
|
CheckCase = false;
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
|
@ -769,6 +769,7 @@ void InterCodeGenerator::InitGlobalVariable(InterCodeModule * mod, Declaration*
|
||||||
{
|
{
|
||||||
dec->mLinkerObject->mType = LOT_INLAY;
|
dec->mLinkerObject->mType = LOT_INLAY;
|
||||||
dec->mInlayRegion->mInlayObject = dec->mLinkerObject;
|
dec->mInlayRegion->mInlayObject = dec->mLinkerObject;
|
||||||
|
dec->mLinkerObject->mFlags &= ~LOBJF_CONST;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8* d = var->mLinkerObject->AddSpace(var->mSize);
|
uint8* d = var->mLinkerObject->AddSpace(var->mSize);
|
||||||
|
|
|
@ -667,6 +667,12 @@ bool NativeCodeInstruction::IsUsedResultInstructions(NumberSet& requiredTemps)
|
||||||
|
|
||||||
// check side effects
|
// check side effects
|
||||||
|
|
||||||
|
if (mFlags & NCIF_VOLATILE)
|
||||||
|
{
|
||||||
|
if (mMode != ASMIM_IMPLIED && mMode != ASMIM_ZERO_PAGE)
|
||||||
|
used = true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case ASMIT_STA:
|
case ASMIT_STA:
|
||||||
|
@ -43871,7 +43877,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate1(int i, int pass)
|
||||||
|
|
||||||
bool NativeCodeBasicBlock::PeepHoleOptimizerIterate2(int i, int pass)
|
bool NativeCodeBasicBlock::PeepHoleOptimizerIterate2(int i, int pass)
|
||||||
{
|
{
|
||||||
if (mIns[i].mType == ASMIT_LDA && mIns[i + 1].mType == ASMIT_LDA)
|
if (mIns[i].mType == ASMIT_LDA && mIns[i + 1].mType == ASMIT_LDA && !(mIns[i].mFlags & NCIF_VOLATILE))
|
||||||
{
|
{
|
||||||
mIns[i].mType = ASMIT_NOP; mIns[i].mMode = ASMIM_IMPLIED;;
|
mIns[i].mType = ASMIT_NOP; mIns[i].mMode = ASMIM_IMPLIED;;
|
||||||
return true;
|
return true;
|
||||||
|
@ -51688,7 +51694,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
|
||||||
mInterProc = proc;
|
mInterProc = proc;
|
||||||
mInterProc->mLinkerObject->mNativeProc = this;
|
mInterProc->mLinkerObject->mNativeProc = this;
|
||||||
|
|
||||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "__prepareScreen__");
|
CheckFunc = !strcmp(mInterProc->mIdent->mString, "cia_init");
|
||||||
|
|
||||||
int nblocks = proc->mBlocks.Size();
|
int nblocks = proc->mBlocks.Size();
|
||||||
tblocks = new NativeCodeBasicBlock * [nblocks];
|
tblocks = new NativeCodeBasicBlock * [nblocks];
|
||||||
|
@ -52664,7 +52670,6 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
if (mEntryBlock->PeepHoleOptimizer(step))
|
if (mEntryBlock->PeepHoleOptimizer(step))
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (step == 2)
|
if (step == 2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5735,6 +5735,7 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
|
||||||
{
|
{
|
||||||
if (ndec->mBase->mType == DT_TYPE_FUNCTION)
|
if (ndec->mBase->mType == DT_TYPE_FUNCTION)
|
||||||
{
|
{
|
||||||
|
if (!(ndec->mFlags & DTF_PLACED))
|
||||||
ndec->mSection = mCodeSection;
|
ndec->mSection = mCodeSection;
|
||||||
|
|
||||||
if ((ndec->mFlags & DTF_DEFINED) && !(ndec->mFlags & DTF_REQUEST_INLINE))
|
if ((ndec->mFlags & DTF_DEFINED) && !(ndec->mFlags & DTF_REQUEST_INLINE))
|
||||||
|
@ -13092,10 +13093,11 @@ void Parser::ParsePragma(void)
|
||||||
if (mScanner->mToken == TK_IDENT)
|
if (mScanner->mToken == TK_IDENT)
|
||||||
{
|
{
|
||||||
Declaration* dec = mGlobals->Lookup(mScanner->mTokenIdent);
|
Declaration* dec = mGlobals->Lookup(mScanner->mTokenIdent);
|
||||||
if (dec && dec->mType == DT_VARIABLE && (dec->mFlags & DTF_GLOBAL))
|
if (dec && (dec->mType == DT_VARIABLE && (dec->mFlags & DTF_GLOBAL) || dec->mType == DT_CONST_FUNCTION))
|
||||||
{
|
{
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
|
|
||||||
|
dec->mFlags |= DTF_PLACED;
|
||||||
dec->mSection = lsec;
|
dec->mSection = lsec;
|
||||||
if (dec->mLinkerObject)
|
if (dec->mLinkerObject)
|
||||||
dec->mLinkerObject->MoveToSection(lsec);
|
dec->mLinkerObject->MoveToSection(lsec);
|
||||||
|
|
Loading…
Reference in New Issue