GCC 3.2 Branch Closure

Graham Stott graham.stott@btinternet.com
Sat Nov 9 13:44:00 GMT 2002


Graham Stott wrote:
> H. J. Lu wrote:
> 
>> On Fri, Nov 08, 2002 at 01:28:53PM +0100, Volker Reichelt wrote:
>>
>>> Hi,
>>>
>>> PR 8502 looks quite severe to me:
>>> It a regression from 3.0.x on the branch where wrong assember code is
>>> generated. However, this problem doesn't occur on mainline.
>>>
>>> Could somebody please have a look at it to decide whether it has to
>>> be fixed for the branch or not?
>>>
>>
>>
>> Here is the modified version for C:
>>
>> ---f.c---
>> int foo (int i)
>> {
>>     switch (i)
>>     {
>>         case 0: return 0;
>>         case 1: return 0;
>>         case 2: return 0;
>>         case 3: return 0;
>>         case 4: return 0;
>>     }
>>
>>     return 0;
>> }
>>
>> int main () { return 0; }
>> ----
>>
>> # /usr/gcc-3.2/bin/gcc f.c
>> /tmp/ccIENiOo.o(.text+0x11): In function `foo':
>> : undefined reference to `.L8'
>> collect2: ld returned 1 exit status
>>
>>
>>
>> H.J.
>>
> 
> Actually mainline does suffer from this undefined label
> problem with reduceable switch statements. The problem
> is we don't always delete dead jumptables.
> 
> I don't have 3.2 checked out at present so it'll take me
> a little while to check out and verify if my mainline patch
> also fixes 3.2
> 
> Graham
> ps. I haven't submitted the mainline patch yet.
> 
> 
> 

It wasn't the same problem.

The problem is we delete the label and jumptable but leave
around the insn which sets up jumptable still references the
label.  This would be OK if we have a chance to tidy this up
but DCE doesn't run post reload.

The following fix from mainline fixes the PR.

bootstrapped regression tested i686-pc-linux-gnu no regressions

OK for 3.2 branch.

Graham

ChangeLog

2002-11-09  Graham Stott  <graham.stott@btinternet.com>
             Jan Hubicka  <jh@suse.cz>

         PR 8502
         * cfgrtl.c (try_redirect_by_replacing_jump): Do not kill computed
         jumps post reload.

------------------------------------------------------------------
Index: cfgrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.29.2.6
diff -c -p -r1.29.2.6 cfgrtl.c
*** cfgrtl.c    15 Jul 2002 16:19:38 -0000      1.29.2.6
--- cfgrtl.c    9 Nov 2002 21:14:17 -0000
*************** try_redirect_by_replacing_jump (e, targe
*** 665,670 ****
--- 665,671 ----
     edge tmp;
     rtx set;
     int fallthru = 0;
+   rtx table;

     /* Verify that all targets will be TARGET.  */
     for (tmp = src->succ; tmp; tmp = tmp->succ_next)
*************** try_redirect_by_replacing_jump (e, targe
*** 672,677 ****
--- 673,685 ----
         break;

     if (tmp || !onlyjump_p (insn))
+     return false;
+
+   if (reload_completed && JUMP_LABEL (insn)
+       && (table = NEXT_INSN (JUMP_LABEL (insn))) != NULL_RTX
+       && GET_CODE (table) == JUMP_INSN
+       && (GET_CODE (PATTERN (table)) == ADDR_VEC
+         || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC))
       return false;

     /* Avoid removing branch with side effects.  */
-------------------------------------------------------------------



More information about the Gcc mailing list