cdp->key = sym->key;
cdp->ancestors = newBitVect(iCodeKey);
cdp->fromGlobal = 0;
+ cdp->fromAddrTaken = 0;
if (ic->op!=IF && ic->op!=JUMPTABLE)
{
{
bitVectSetBit (cdp->ancestors, IC_LEFT (ic)->key);
cdp->fromGlobal |= isOperandGlobal (IC_LEFT (ic));
+ cdp->fromAddrTaken |= OP_SYMBOL (IC_LEFT (ic))->addrtaken;
}
if (IC_RIGHT (ic) && IS_SYMOP (IC_RIGHT (ic)))
{
bitVectSetBit (cdp->ancestors, IC_RIGHT (ic)->key);
cdp->fromGlobal |= isOperandGlobal (IC_RIGHT (ic));
+ cdp->fromAddrTaken |= OP_SYMBOL (IC_RIGHT (ic))->addrtaken;
}
}
{
cdp->ancestors = bitVectUnion (cdp->ancestors, loop->ancestors);
cdp->fromGlobal |= loop->fromGlobal;
+ cdp->fromAddrTaken |= loop->fromAddrTaken;
break;
}
}
{
cdp->ancestors = bitVectUnion (cdp->ancestors, loop->ancestors);
cdp->fromGlobal |= loop->fromGlobal;
+ cdp->fromAddrTaken |= loop->fromAddrTaken;
break;
}
}
return (isOperandGlobal (cdp->sym));
}
+/*-------------------------------------------------------------------*/
+/* ifFromAddrTaken - if definition is derived from a symbol whose */
+/* address was taken */
+/*-------------------------------------------------------------------*/
+DEFSETFUNC (ifFromAddrTaken)
+{
+ cseDef *cdp = item;
+
+ return cdp->fromAddrTaken;
+}
+
+
/*-----------------------------------------------------------------*/
/* ifAnyGetPointer - if get pointer icode */
/*-----------------------------------------------------------------*/
ifxOptimize (iCode * ic, set * cseSet,
int computeOnly,
eBBlock * ebb, int *change,
- eBBlock ** ebbs, int count)
+ ebbIndex * ebbi)
{
operand *pdop;
symbol *label;
/* this is very expensive but it does not happen */
/* too often, if it does happen then the user pays */
/* the price */
- computeControlFlow (ebbs, count, 1);
+ computeControlFlow (ebbi);
if (!options.lessPedantic) {
werrorfl (ic->filename, ic->lineno, W_CONTROL_FLOW);
}
we can remove this conditional statement */
label = (IC_TRUE (ic) ? IC_TRUE (ic) : IC_FALSE (ic));
if (elementsInSet (ebb->succList) == 1 &&
- isinSet (ebb->succList, eBBWithEntryLabel (ebbs, label, count)))
+ isinSet (ebb->succList, eBBWithEntryLabel (ebbi, label)))
{
if (!options.lessPedantic) {
else
{
remiCodeFromeBBlock (ebb, ic);
- computeControlFlow (ebbs, count, 1);
+ computeControlFlow (ebbi);
return;
}
}
ic->op != '-')
return 0;
- /* this check is a hueristic to prevent live ranges
+ /* this check is a heuristic to prevent live ranges
from becoming too long */
if (IS_PTR (operandType (IC_RESULT (ic))))
return 0;
return 0;
/* check if we can find a definition for the
- right hand side */
+ left hand side */
if (!(applyToSet (cseSet, diCodeForSym, IC_LEFT (ic), &dic)))
return 0;
/*-----------------------------------------------------------------*/
int
cseBBlock (eBBlock * ebb, int computeOnly,
- eBBlock ** ebbs, int count)
+ ebbIndex * ebbi)
{
+ eBBlock ** ebbs = ebbi->bbOrder;
+ int count = ebbi->count;
set *cseSet;
iCode *ic;
int change = 0;
since they can be modified by the function call */
deleteItemIf (&cseSet, ifDefGlobal);
- /* and also itemps derived from globals */
+ /* and also iTemps derived from globals */
deleteItemIf (&cseSet, ifFromGlobal);
+
+ /* Delete iTemps derived from symbols whose address */
+ /* has been taken */
+ deleteItemIf (&cseSet, ifFromAddrTaken);
/* delete all getpointer iCodes from cseSet, this should
be done only for global arrays & pointers but at this
{
ifxOptimize (ic, cseSet, computeOnly,
ebb, &change,
- ebbs, count);
+ ebbi);
continue;
}
/* left operand */
/* and left is a symbol */
if (IS_SYMOP (IC_LEFT (ic)) &&
+ !IS_BITFIELD (OP_SYM_ETYPE (IC_LEFT (ic))) &&
!computeOnly && ic->op != ADDRESS_OF)
{
/* if after all this it becomes an assignment to self
then delete it and continue */
- if (ASSIGNMENT_TO_SELF (ic))
+ if (ASSIGNMENT_TO_SELF (ic) && !isOperandVolatile (IC_RIGHT(ic), FALSE))
{
remiCodeFromeBBlock (ebb, ic);
continue;
/* cseAllBlocks - will sequentially go thru & do cse for all blocks */
/*-----------------------------------------------------------------*/
int
-cseAllBlocks (eBBlock ** ebbs, int count, int computeOnly)
+cseAllBlocks (ebbIndex * ebbi, int computeOnly)
{
+ eBBlock ** ebbs = ebbi->dfOrder;
+ int count = ebbi->count;
int i;
int change = 0;
/* if optimization turned off */
for (i = 0; i < count; i++)
- change += cseBBlock (ebbs[i], computeOnly, ebbs, count);
+ change += cseBBlock (ebbs[i], computeOnly, ebbi);
return change;
}