more LRH debugging junk
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 12 Mar 2003 12:34:58 +0000 (12:34 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 12 Mar 2003 12:34:58 +0000 (12:34 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2381 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCBBlock.h
src/SDCCcflow.c
src/SDCCloop.c

index fab3f8986eb283aab6206ce20d6ef3f098eb3aca..c455ed7b9798d8915a0cc71a2a3a48c20b48e353 100644 (file)
@@ -38,6 +38,7 @@ typedef struct eBBlock
     unsigned int hasFcall:1;   /* has a function call */
     unsigned int noPath:1;     /* there is no path from _entry to this block */
     unsigned int isLastInLoop:1;       /* is the last block in a loop */
+    unsigned int hasConditionalExit; /* this block ends with a return or goto from a conditional block*/
     symbol *entryLabel;                /* entry label */
 
     iCode *sch;                        /* pointer to start of code chain */
index aff9a856b1ac0778bdcd49cefd3269a1b7638aee..2da48baa65430991aebd56a1ed34b4d16e0d74a4 100644 (file)
@@ -1,3 +1,9 @@
+//#define LIVERANGEHUNT
+#ifdef LIVERANGEHUNT
+  #define LRH(x) x
+#else
+  #define LRH(x)
+#endif
 /*-------------------------------------------------------------------------
 
   SDCCcflow.c - source file for control flow analysis
@@ -131,6 +137,18 @@ eBBSuccessors (eBBlock ** ebbs, int count)
 
                  addSuccessor (ebbs[i], ebbs[j]);      /* add it */
                }
+             else
+               {
+                 int j=i;
+                 while (j--) {
+                   if (ebbs[j]->ech && ebbs[j]->ech->op==IFX &&
+                       (isSymbolEqual(IC_TRUE(ebbs[j]->ech), ebbs[i]->entryLabel) ||
+                        isSymbolEqual(IC_FALSE(ebbs[j]->ech), ebbs[i]->entryLabel))) {
+                     LRH(printf ("%s has a conditional exit from %s\n", ebbs[i]->entryLabel->name, ebbs[j]->entryLabel->name));
+                     ebbs[i]->hasConditionalExit=1;
+                   }
+                 }
+               }
            }                   /* no instructions in the block */
          /* could happen for dummy blocks */
          else
index 21d16bacd661e572d10619a1a18f420bde57d648..dbad1e4c90f8ce22a18f64de2632a6d0456fdab2 100644 (file)
@@ -324,6 +324,23 @@ DEFSETFUNC (createLoop)
 #endif
 
   aloop->entry = ep->to;
+
+#ifdef LIVERANGEHUNT
+  // now also include those blocks that conditionally escape from this loop 
+  for (i=1; i<count; i++) {
+    if (ebbs[i]->hasConditionalExit) {
+      for (block=setFirstItem(aloop->regBlocks); 
+          block; 
+          block=setNextItem(aloop->regBlocks)) {
+       if (isinSet(block->predList, ebbs[i])) {
+         printf ("%s has a forced exit from %s\n", 
+                 ebbs[i]->entryLabel->name, 
+                 block->entryLabel->name);
+       }
+      }
+    }
+  }    
+#else
   /* set max & min dfNum for loopRegion */
   for ( block = setFirstItem(aloop->regBlocks); block; 
        block = setNextItem(aloop->regBlocks)) {
@@ -338,14 +355,11 @@ DEFSETFUNC (createLoop)
           ebbs[i]->dfnum < dfMax &&
          !isinSet(aloop->regBlocks,ebbs[i])) {
          if (!ebbs[i]->partOfLoop) {
-#if !defined(LIVERANGEHUNT)
            ebbs[i]->partOfLoop = aloop;
-#else
-           loopInsert(&aloop->regBlocks,ebbs[i]);
-#endif
          }
       }
   }
+#endif
 
 #ifdef LIVERANGEHUNT
   printf ("================\n");