From: SourceForge.net <no...@so...> - 2003-02-24 12:41:02
|
Bugs item #690781, was opened at 2003-02-21 17:38 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=690781&group_id=599 Category: C-Front End >Group: fixed >Status: Closed Resolution: None Priority: 5 Submitted By: Erik Petrich (epetrich) >Assigned to: Johan Knol (johanknol) Summary: False optimization (key confusion) Initial Comment: This one is a cousin to bug #628025 fixed earlier. The key assigned to a parameter passed to a function is now getting confused with another iTemp in the caller that happens to have the same key. Since SDCCcse.c is riddled with key comparisions, rather than sprinkling more IS_OTHERSPARM marcros around, the keys to other function's parameters could be assigned a nonoverlapping range with the current function's operands (for example, make them all negative). In any case, I don't feel confident enough to make such drastic changes on my own at this time. Here's some sample c code: extern char func1(char x, char y); char func2(void) { if (!func1(1,2)) return 1; if (!func1(2,3)) return 1; return 0; } char func3(void) { if (!func1(1,2)) return 1; // <-bug if (!func1(2,3)) return 1; return 0; } Here's the iCode for the problematic line: send 0x1 {literal char}{argreg = 1} _func1_PARM_2 [k3 lr0:0 so:0]{ ia1 re0 rm0 nos0 ru0 dp0}{char} := 0x2 {literal char} iTemp0 [k3 lr0:0 so:0]{ ia0 re0 rm0 nos0 ru0 dp0}{char} = call _func1 [k2 lr0:0 so:0]{ ia0 re0 rm0 nos0 ru0 dp0}{char function } if iTemp0 [k3 lr0:0 so:0]{ ia0 re0 rm0 nos0 ru0 dp0}{char} != 0 goto _iffalse_2($2) The second parameter and the function result both have key 3, so the optimizer effectively turns this into func1(1,2); if (!2) return 1; Key confusion aside, this also seems a bad optimization in that the literal 2 is stale by this point. ---------------------------------------------------------------------- >Comment By: Johan Knol (johanknol) Date: 2003-02-24 12:49 Message: Logged In: YES user_id=63512 The IS_OTHERS_PARM was a bad fix. The keys of function parameters needs to be reset for every new function, but that didn't happen for prototypes. I fixed that in SDCCsymt.c:141 and removed the bad fix. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=690781&group_id=599 |