- iCode *ic;
- bitVect *defsUsed = NULL;
- bitVect *defsNotUsed = NULL;
- int i;
- /* for all the instructions */
- for (ic = ebp->sch ; ic ; ic = ic->next ) {
-
- if (ic->op == CALL || ic->op == PCALL) {
- setFromRange(IC_RESULT(ic),ic->seq);
- /* if the result has no usage then
- mark this as the end of its life too
- and take it away from the defs for the block*/
- if (bitVectIsZero(OP_SYMBOL(IC_RESULT(ic))->uses)) {
- setToRange(IC_RESULT(ic),ic->seq,FALSE);
- bitVectUnSetBit(ebp->defSet,ic->key);
+ int i, key;
+ eBBlock *succ;
+ bitVect *alive;
+
+ /* for all blocks do */
+ for (i = 0; i < count; i++)
+ {
+ iCode *ic;
+
+ /* for all instructions in this block do */
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+
+ if (!ic->rlive)
+ ic->rlive = newBitVect (operandKey);
+
+ if (SKIP_IC2(ic))
+ continue;
+
+ if (ic->op == JUMPTABLE && IS_SYMOP(IC_JTCOND(ic)))
+ {
+ incUsed (ic, IC_JTCOND(ic));
+
+ if (!IS_AUTOSYM(IC_JTCOND(ic)))
+ continue;
+
+ findPrevUse (ebbs[i], ic, IC_JTCOND(ic), ebbs, count, emitWarnings);
+ if (IS_ITEMP(IC_JTCOND(ic)))
+ {
+ unvisitBlocks(ebbs, count);
+ ic->rlive = bitVectSetBit (ic->rlive, IC_JTCOND(ic)->key);
+ findNextUse (ebbs[i], ic->next, IC_JTCOND(ic));
+ }
+
+ continue;
+ }
+
+ if (ic->op == IFX && IS_SYMOP(IC_COND(ic)))
+ {
+ incUsed (ic, IC_COND(ic));
+
+ if (!IS_AUTOSYM(IC_COND(ic)))
+ continue;
+
+ findPrevUse (ebbs[i], ic, IC_COND(ic), ebbs, count, emitWarnings);
+ if (IS_ITEMP(IC_COND(ic)))
+ {
+ unvisitBlocks (ebbs, count);
+ ic->rlive = bitVectSetBit (ic->rlive, IC_COND(ic)->key);
+ findNextUse (ebbs[i], ic->next, IC_COND(ic));
+ }
+
+ continue;
+ }
+
+ if (IS_SYMOP(IC_LEFT(ic)))
+ {
+ incUsed (ic, IC_LEFT(ic));
+ if (IS_AUTOSYM(IC_LEFT(ic)) &&
+ ic->op != ADDRESS_OF)
+ {
+ findPrevUse (ebbs[i], ic, IC_LEFT(ic), ebbs, count, emitWarnings);
+ if (IS_ITEMP(IC_LEFT(ic)))
+ {
+ unvisitBlocks(ebbs, count);
+ ic->rlive = bitVectSetBit (ic->rlive, IC_LEFT(ic)->key);
+ findNextUse (ebbs[i], ic->next, IC_LEFT(ic));
+
+ /* if this is a send extend the LR to the call */
+ if (ic->op == SEND)
+ {
+ iCode *lic;
+ for (lic = ic; lic; lic = lic->next)
+ {
+ if (lic->op == CALL || lic->op == PCALL)
+ {
+ markAlive (ic, lic->prev, IC_LEFT (ic)->key);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (IS_SYMOP(IC_RIGHT(ic)))
+ {
+ incUsed (ic, IC_RIGHT(ic));
+ if (IS_AUTOSYM(IC_RIGHT(ic)))
+ {
+ findPrevUse (ebbs[i], ic, IC_RIGHT(ic), ebbs, count, emitWarnings);
+ if (IS_ITEMP(IC_RIGHT(ic)))
+ {
+ unvisitBlocks(ebbs, count);
+ ic->rlive = bitVectSetBit (ic->rlive, IC_RIGHT(ic)->key);
+ findNextUse (ebbs[i], ic->next, IC_RIGHT(ic));
+ }
+ }
+ }
+
+ if (POINTER_SET(ic) && IS_SYMOP(IC_RESULT(ic)))
+ incUsed (ic, IC_RESULT(ic));
+
+ if (IS_AUTOSYM(IC_RESULT(ic)))
+ {
+ if (POINTER_SET(ic))
+ {
+ findPrevUse (ebbs[i], ic, IC_RESULT(ic), ebbs, count, emitWarnings);
+ }
+ if (IS_ITEMP(IC_RESULT(ic)))
+ {
+ unvisitBlocks(ebbs, count);
+ ic->rlive = bitVectSetBit (ic->rlive, IC_RESULT(ic)->key);
+ findNextUse (ebbs[i], ic->next, IC_RESULT(ic));
+ }