From 40cd2beaddfccdd440379feea8eaa52ab65c040c Mon Sep 17 00:00:00 2001 From: johanknol Date: Wed, 12 Mar 2003 12:34:58 +0000 Subject: [PATCH] more LRH debugging junk git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2381 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCBBlock.h | 1 + src/SDCCcflow.c | 18 ++++++++++++++++++ src/SDCCloop.c | 22 ++++++++++++++++++---- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/SDCCBBlock.h b/src/SDCCBBlock.h index fab3f898..c455ed7b 100644 --- a/src/SDCCBBlock.h +++ b/src/SDCCBBlock.h @@ -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 */ diff --git a/src/SDCCcflow.c b/src/SDCCcflow.c index aff9a856..2da48baa 100644 --- a/src/SDCCcflow.c +++ b/src/SDCCcflow.c @@ -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 diff --git a/src/SDCCloop.c b/src/SDCCloop.c index 21d16bac..dbad1e4c 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -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; ihasConditionalExit) { + 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"); -- 2.30.2