Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.25
 
1.26
 
MAIN:ragge:20050628132900
 
optim2.c
_>289289         epp = (struct interpass_prolog *)ip;
 290290         saving = -1;
 291291 
<>292 -        //              deljumps();     /* Delete redundant jumps and dead code */
  292+ipp = (struct interpass_prolog *)DLIST_NEXT(&ipole, qelem);
  293+printf("inlab %d utlab %d\n", ipp->ip_lblnum, epp->ip_lblnum);
  294+        if (xdeljumps)
  295+                deljumps();     /* Delete redundant jumps and dead code */
293296         if (xssaflag) {
 294297                 DLIST_INIT(&bblocks, bbelem);
 295298                 if (bblocks_build(&labinfo, &bbinfo)) {
     
 !
403406         DLIST_INIT(&ipole, qelem);
 404407 }
 405408 
<> 409+/*
  410+ * Delete unused labels, excess of labels, gotos to gotos.
  411+ * This routine can be made much more efficient.
  412+ */
406413 void
 407414 deljumps()
 408415 {
<>409 -        struct interpass *ip, *n;
 410 -        int gotone;
  416+        struct interpass_prolog *ipp, *epp;
  417+        struct interpass *ip, *n, *ip2;
  418+        int gotone,low, high;
  419+        int *lblary, i, sz, o;
411420 
<> 421+        ipp = (struct interpass_prolog *)DLIST_NEXT(&ipole, qelem);
  422+        epp = (struct interpass_prolog *)DLIST_PREV(&ipole, qelem);
  423+
  424+        low = ipp->ip_lblnum;
  425+        high = epp->ip_lblnum;
  426+
  427+#ifdef notyet
  428+        mark = tmpmark(); /* temporary used memory */
  429+#endif
  430+#define FOUND   1
  431+#define REFD    2
  432+        sz = (high-low) * sizeof(int);
  433+        lblary = tmpalloc(sz);
  434+        memset(lblary, 0, sz);
  435+
412436 again:  gotone = 0;
 413437 
<> 438+printip(&ipole);
  439+
  440+        /* Delete all goto/branch to the following label */
414441         DLIST_FOREACH(ip, &ipole, qelem) {
<> 442+                if (ip->type == IP_DEFLAB) {
  443+                        lblary[ip->ip_lbl-low] |= FOUND;
  444+printf("IP_DEFLAB: %d\n", ip->ip_lbl);
  445+                        ip2 = DLIST_NEXT(ip, qelem);
  446+printf("ip2 %d\n", ip2->type);
  447+                        while (ip2->type == IP_DEFLAB ||
  448+                            ip2->type == IP_STKOFF) {
  449+                                if (ip2->type == IP_DEFLAB) {
  450+                                        lblary[ip2->ip_lbl-low] = -ip->ip_lbl;
  451+printf("coal %d\n", ip2->ip_lbl);
  452+                                        DLIST_REMOVE(ip2, qelem);
  453+                                        gotone = 1;
  454+                                } else
  455+                                        ip = ip2;
  456+                                ip2 = DLIST_NEXT(ip, qelem);
  457+                        }
  458+                        ip = DLIST_PREV(ip, qelem);
  459+                        continue;
  460+                }
  461+                n = DLIST_NEXT(ip, qelem);
  462+                if (n->type != IP_NODE)
  463+                        continue;
  464+                o = n->ip_node->n_op;
  465+                if (o == GOTO)
  466+                        i = n->ip_node->n_left->n_lval;
  467+                else if (o == CBRANCH)
  468+                        i = n->ip_node->n_right->n_lval;
  469+                else
  470+                        continue;
  471+                if (lblary[i-low] < 0) {
  472+                        if (o == GOTO)
  473+                                n->ip_node->n_left->n_lval = -lblary[i-low];
  474+                        else
  475+                                n->ip_node->n_right->n_lval = -lblary[i-low];
  476+                        gotone = 1;
  477+                }
  478+                ip2 = DLIST_NEXT(n, qelem);
  479+                if (ip2->type == IP_DEFLAB && ip2->ip_lbl == i) {
  480+                        tfree(n->ip_node);
  481+                        DLIST_REMOVE(n, qelem);
  482+                        gotone = 1;
  483+                }
  484+        }
  485+        if (gotone)
  486+                goto again;
  487+
  488+#ifdef notyet
  489+        tmpfree(mark);
  490+#endif
  491+
  492+#if 0
  493+        DLIST_FOREACH(ip, &ipole, qelem) {
  494+                if (ip->type == IP_DEFLAB) {
  495+                        lblary[ip->ip_lbl-low] |= FOUND;
  496+                        ip2 = DLIST_NEXT(ip, qelem);
  497+                        while (ip2->type == IP_DEFLAB) {
  498+                                lblary[ip2->ip_lbl-low] = -ip->ip_lbl;
  499+                                DLIST_REMOVE(ip2, qelem);
  500+                                ip2 = DLIST_NEXT(ip, qelem);
  501+                        }
  502+                }
  503+                if (ip->type != IP_NODE)
  504+                        continue;
  505+                if (o == GOTO)
  506+                        i = ip->ip_node->n_left->n_lval;
  507+                else if (o == CBRANCH)
  508+                        i = ip->ip_node->n_right->n_lval;
  509+                else
  510+                        continue;
  511+                if (lblary[i-low] < 0) {
  512+                        /* coalesced */
  513+                        
  514+                lblary[i-low] |= REFD;
  515+        }
  516+
  517+
  518+
  519+
  520+again:  gotone = 0;
  521+
  522+
  523+
  524+
  525+
  526+
  527+
  528+        DLIST_FOREACH(ip, &ipole, qelem) {
415529                 if (ip->type == IP_EPILOG)
 416530                         return;
 417531                 if (ip->type != IP_NODE)
     
 !
438552         }
 439553         if (gotone)
 440554                 goto again;
<> 555+#endif
<_441556 }
 442557 
 443558 void
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-10-30 16:15 +0100